|
Subject:
|
Retrieving Data From Multiple Databases
|
|
Posted By:
|
Macsood
|
Post Date:
|
12/13/2005 9:41:07 AM
|
i want to select from many databases, for example , i want to select table master in database A, and table master in database B. can i do it like this : " select * from A.Master, B.Master " just like in SQL Server ?? or can somebody help me how to do that?? Thank u....
|
|
Reply By:
|
SqlMenace
|
Reply Date:
|
12/13/2005 9:47:03 AM
|
select * from a.dbo.master union all select * from b.dbo.master
assuming the tables are identical you will get 1 row for each, if you want combined rows you need to do a join
“I sense many useless updates in you... Useless updates lead to fragmentation... Fragmentation leads to downtime...Downtime leads to suffering..Fragmentation is the path to the darkside.. DBCC INDEXDEFRAG and DBCC DBREINDEX are the force...May the force be with you" -- http://sqlservercode.blogspot.com/
|
|
Reply By:
|
Macsood
|
Reply Date:
|
12/13/2005 2:08:42 PM
|
Let me give you an example.Lets say i want to retreve field au_name from table authors in database pubs
AND
field customerid from table customers in database northwind at the same time.
Now what will be the query for that?
|
|
Reply By:
|
SqlMenace
|
Reply Date:
|
12/13/2005 2:25:20 PM
|
select distinct a.au_lname,c.customerid from pubs.dbo.authors a,northwind.dbo.customers c --what would the join condition be here
select au_lname,'authors' as tablename from pubs.dbo.authors union all select customerid ,'customer' as customers from northwind.dbo.customers
“I sense many useless updates in you... Useless updates lead to fragmentation... Fragmentation leads to downtime...Downtime leads to suffering..Fragmentation is the path to the darkside.. DBCC INDEXDEFRAG and DBCC DBREINDEX are the force...May the force be with you" -- http://sqlservercode.blogspot.com/
|