Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

SQL Server Linked Server with variable command

482162Jan 11 2006 — edited Jan 12 2006
Hi All,

I'm working in SQL Server 2005 using a Linked Server against an Oracle 10 database. The linked server works correctly in that I can do:

Select * From OpenQuery(DssPrd, 'Select * From DwDba.Admit_Priority')

I'd like to be able to build the query string on the fly, eventually to add a variable to the string, and send the string variable. Something like this:

Declare @Sql Char(100)
Set @Sql = 'Select * From DwDba.Admit_Priority Where Admit_Priority = 5'
Select * From OpenQuery(DssPrd, @Sql)

Of course that doesn't work but is there any way to pass a variable in the OpenQuery() statement? (I've asked in a SQL Server forum with no responses yet.)

Thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 9 2006
Added on Jan 11 2006
3 comments
1,143 views