|
-
March 15th, 2007, 10:16 AM
#1
Dynamic DB Selection
I'm using SQL Server 2000 and am looking for a way to dynamically select which database to select from in a stored procedure.
I have 4 possible DBs to choose from and don't want to write 5 SPs: 1 to choose which DB and 1 for each DB, simply changing the [db].dbo.tableName, know what I mean.
I'm aware of the exec('SELECT * FROM [db].dbo.tableName') option, but I'm looking for a (hopefully) easier solution.
Something like SELECT * FROM @myDB.dbo.tableName (which doesn't work).
Anyone have any suggestions?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|