Wednesday, March 28, 2012

openquery

BOL says that 'OPENQUERY does not accept variables for its
arguments'. So, I tried using something like:
Declare @.qry varchar(1000)
Set @.qry = 'select * from OPENQUERY
(<linked_server_name>, ''<query>'')'
exec (@.qry)
Would this work? Thanks.Yes.
--
-oj
RAC v2.2 & QALite!
http://www.rac4sql.net
"Rob" <anonymous@.discussions.microsoft.com> wrote in message
news:018301c3ad3f$50936e10$a401280a@.phx.gbl...
> BOL says that 'OPENQUERY does not accept variables for its
> arguments'. So, I tried using something like:
> Declare @.qry varchar(1000)
> Set @.qry = 'select * from OPENQUERY
> (<linked_server_name>, ''<query>'')'
> exec (@.qry)
> Would this work? Thanks.|||That is called Dynamic SQL and should work if the final syntax comes out
correct.
--
Geoff N. Hiten
Microsoft SQL Server MVP
Senior Database Administrator
Careerbuilder.com
"Rob" <anonymous@.discussions.microsoft.com> wrote in message
news:018301c3ad3f$50936e10$a401280a@.phx.gbl...
> BOL says that 'OPENQUERY does not accept variables for its
> arguments'. So, I tried using something like:
> Declare @.qry varchar(1000)
> Set @.qry = 'select * from OPENQUERY
> (<linked_server_name>, ''<query>'')'
> exec (@.qry)
> Would this work? Thanks.

No comments:

Post a Comment