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)
 selecting from 2 DBs in a stored proc

Author  Topic 

PeterG
Posting Yak Master

156 Posts

Posted - 2002-04-26 : 11:50:19
I want to do this:
* select a dbname from a table in db1
* when i have the dbname, do a select from a table in that dbname

db1 and dbname reside in the same server. I don't know if this can be done. Any ideas would be very much appreciated. Thank you.



Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2002-04-26 : 11:53:34
take a look at Merkin's article on Dynamic SQL.

What you want to do can be done . . . quite easily.

<O>

Edited by - Page47 on 04/26/2002 11:54:19
Go to Top of Page

VyasKN
SQL Server MVP &amp; SQLTeam MVY

313 Posts

Posted - 2002-04-26 : 11:56:26
You need to use dynamic SQL, which is good as well as bad. For more info, please read this FAQ entry at my site: http://vyaskn.tripod.com/programming_faq.htm#q9

--
HTH,
Vyas
Check out my SQL Server site @
http://vyaskn.tripod.com
Go to Top of Page
   

- Advertisement -