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.
Author |
Topic |
loneregister
Starting Member
6 Posts |
Posted - 2008-04-15 : 18:49:24
|
I wish to form a query that pulls data across databases dynamically.For example:I have a table with a field that indicates which database the data resides in. Based on the results of this field I wish to change which database the data is pulling from.Something likeselect dbasename, (select value from dbasename.dbo.othertable where x = y) from masterdatabaseCan anyone help me do this? |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-04-16 : 01:25:06
|
Are all your databases in same server? |
 |
|
loneregister
Starting Member
6 Posts |
Posted - 2008-04-16 : 16:52:56
|
Yes. |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-04-16 : 16:57:23
|
select s.dbasename, t.value from masterdatabase as sleft join dbasename.dbo.othertable as t on t.x = s.y E 12°55'05.25"N 56°04'39.16" |
 |
|
|
|
|