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 |
|
joelseverich
Starting Member
34 Posts |
Posted - 2008-01-10 : 11:17:00
|
| Hi I'm trying to select data from different databases, Actually databases have the same structure and tables but different data, so I want to mix data from specific tables of all databases.Any help would be great |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-01-10 : 11:21:58
|
| Are all the databases in same server? If yes, use:-SELECT field1,field2,... FROM DB1.<schema>.TableUNION ALLSELECT field1,field2,... FROM DB2.<schema>.TableUNION ALLSELECT field1,field2,... FROM DB3.<schema>.Table..... |
 |
|
|
joelseverich
Starting Member
34 Posts |
Posted - 2008-01-10 : 11:51:08
|
| I tried this but it says "DB2.... is not a valid object" |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-01-10 : 11:53:34
|
| the format is <dbname>.<schemaname>.<tablename>so if your db=DB1schema=sc1tablename =t1thenSELECT * FROM DB1.sc1.t1 |
 |
|
|
joelseverich
Starting Member
34 Posts |
Posted - 2008-01-10 : 12:02:18
|
| I changed some parameters and it worked thank you... |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
|
|
|