Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 select query using linked server and odbc driver.

Author  Topic 

spatemp
Starting Member

11 Posts

Posted - 2005-06-13 : 09:10:02
I have created a linked server in sql server to IBM DB2 database using Microsoft OLE DB provider for ODBC. I am writing a stored procedure that would retrieve data from DB2. I am struggling on exactly how to execute this query. I have used the following syntex, however it is getting little harder with escaping single quotes etc ...

select * from OPENQUERY( LINKEDSEVER, 'SELECT * from where date_column = {d ''2005-05-10'' }' );

Is there a better way to execute the query to linked sever. Also, I need to substitue parameters to this query. Is that possible?

Thanks for any help.

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-06-13 : 09:21:52
Is this you want?

SELECT * from LinkedServer.dbo.DBName.TableName where date_column = '2005-05-10'


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

spatemp
Starting Member

11 Posts

Posted - 2005-06-13 : 09:51:25
Yes. I have not tried this but I guess it should work. Now the next question is can you substitute parameters to this query.

quote:
Originally posted by madhivanan

Is this you want?

SELECT * from LinkedServer.dbo.DBName.TableName where date_column = '2005-05-10'


Madhivanan

Failing to plan is Planning to fail

Go to Top of Page
   

- Advertisement -