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
 SQL Server Development (2000)
 Dynamic Server-Database-Owner-Table

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-05-11 : 08:20:45
Bill writes "I would like to create a query but the server name and database name are dynamic. How can I pass the server name and database name to a stored procedure and select from a table that resides on the server and database specified by the parameter. I would prefer not to use exec(@SqlCmdStr) because the queries can be very complicated and contain many other parameters as well

Thanks, Bill"

nr
SQLTeam MVY

12543 Posts

Posted - 2006-05-11 : 08:33:27
There's not much of an option other than to execute a string.
If you limit the list then you can code a series of case statements.
You could use a view maybe but that would still need a list of server/databases

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -