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 2005 Forums
 Transact-SQL (2005)
 Stored Proc and Parameters

Author  Topic 

RyanAustin
Yak Posting Veteran

50 Posts

Posted - 2007-11-22 : 16:40:52
I need to rewrite a stored proc so that it passes a parameter for an Oracle Linked server. I can do this when I use the EXEC ('') for the TSQL and it works fine. For example EXEC('select * from openquery('+@link+',''select name from v$database'')') The @Link parameter takes my parameter and it returns the correct value from the Oracle database. Now this is assuming that the user entered in the correct Oracle Linked server name.

Now if I run this without the EXEC it will not work. If I use SELECT * FROM OPENQUERY (@Link,'select name from v$database') it errors out. Is there another way to correctly write this?

Thank you.

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-11-22 : 16:59:07
moved from script library

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com
Go to Top of Page
   

- Advertisement -