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 |
|
rcr69er
Constraint Violating Yak Guru
327 Posts |
Posted - 2008-10-01 : 07:18:16
|
| HiI have two databases – Database1 and Database2 (Original names I know!!!). Both have the exact same structure but different data as each database belongs to a different company.I have produced a Select statement for one of the databases in which I want to Union using the same Select statement with the other database. Is this possible to do?Thanks |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2008-10-01 : 07:25:26
|
| SELECT <columns>FROM [database1].dbo.tableUNIONSELECT <columns>FROM [database2].dbo.table |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-01 : 07:27:17
|
| Are databases in same server? If yes just use four part naming convention as db.schema.tablename.If not add one as linked server on other server and use as above.or use OPENROWSET |
 |
|
|
rcr69er
Constraint Violating Yak Guru
327 Posts |
Posted - 2008-10-01 : 07:44:38
|
| HiThanks for that guys.Yes the databases are going to be on the same server.Thanks |
 |
|
|
|
|
|