Reputation: 75
I am running a query on linked server (IBM DB2) the reason I am doing this is because it takes lot of time to execute a simple query. below are the two queries, the first one runs successfully so the issue is not with the query
select top 10 * from [AS400TS_LNK].[TEST].[AUPRDDBF].CONTACCT where actrno = '8971'
select * from openquery(AS400TS_LNK, 'select * from [TEST].[AUPRDDBF].CONTACCT where actrno = ''8971''')
and the error I get while running the open query
OLE DB provider "DB2OLEDB" for linked server "AS400TS_LNK" returned message "Token *N was not valid. Valid tokens: *N. SQLSTATE: 42601, SQLCODE: -104".
Msg 7321, Level 16, State 2, Line 1
An error occurred while preparing the query "select * from [AS400TS_LNK].[TEST].[AUPRDDBF].CONTACCT where actrno = '8971'" for execution against OLE DB provider "DB2OLEDB" for linked server "AS400TS_LNK".
Upvotes: 1
Views: 1734
Reputation: 32145
Try this:
select *
from openquery(AS400TS_LNK, 'select * from TEST.AUPRDDBF.CONTACCT where actrno = ''8971''')
Or, failing that, try this:
select *
from openquery(AS400TS_LNK, 'select * from TEST.AUPRDDBF.CONTACCT')
where actrno = '8971'
Upvotes: 1