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
 Old Forums
 CLOSED - General SQL Server
 Openquery and variables

Author  Topic 

ineedhelp
Starting Member

11 Posts

Posted - 2005-02-16 : 12:59:29
Hi,

Microsoft website states clearly that "OPENQUERY does not accept variables for its arguments". Is there a workaround this?

Basically, I want get the linked server name, catalog name, schema name etc from another table.

So the least I have to achieve is the following:

SELECT * FROM openquery ( @myserver, 'select * from tablename')

Any ideas? Thanks

Thanks

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-02-16 : 13:01:07
use dynamic sql:
exec('SELECT * FROM openquery ( ' + @myserver + ', '''select * from tablename''')'

Go with the flow & have fun! Else fight the flow
Go to Top of Page

ineedhelp
Starting Member

11 Posts

Posted - 2005-02-16 : 14:15:53
Thanks a ton, spirit1.

Thanks
Go to Top of Page
   

- Advertisement -