一个无厘头的SQL出错 declare @maxTime varchar(25) select @maxTime=''''+max(CONTACTENDTIME)+'''' from T_Pub_CommonInfo
SELECT * FROM openquery(ORA8172,'SELECT * FROM ICDMAIN.T_PUB_COMMONINFO WHERE CONTACTENDTIME>'+@maxTime+' AND STAFFCITY =''05'' AND ACCEPTERNO IN (''4085'',''4086'',''4087'',''4088'',''4089'',''4090'',''4096'')')
set @str='SELECT * FROM ICDMAIN.T_PUB_COMMONINFO WHERE CONTACTENDTIME>'+@maxTime+' AND STAFFCITY =''05'' AND ACCEPTERNO IN (''4085'',''4086'',''4087'',''4088'',''4089'',''4090'',''4096'')'
OPENQUERY 不接受其参数的变量
------解决方案-------------------- declare @maxTime varchar(25) select @maxTime=trim(max(CONTACTENDTIME)) from T_Pub_CommonInfo
SELECT * FROM openquery(ORA8172,'SELECT * FROM ICDMAIN.T_PUB_COMMONINFO WHERE CONTACTENDTIME>'''+@maxTime+''' AND STAFFCITY =''05'' AND ACCEPTERNO IN (''4085'',''4086'',''4087'',''4088'',''4089'',''4090'',''4096'')')
------解决方案--------------------