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 2005 Forums
 Transact-SQL (2005)
 Combining Two databases

Author  Topic 

vijayanto
Starting Member

16 Posts

Posted - 2009-06-19 : 04:10:11
hi friends,
i plan to get datas from two databases in sql query
and the two databases contain different tables
i want to the table datas from those two databases

regards
vijay

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2009-06-19 : 07:24:21
My guess is that you want data from tables that are in different databases? Are the tables linked in any way? Are they on different servers? This might help

Select <columns> from [databasename].[objectowner].table


Jim
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-06-20 : 02:22:26
quote:
Originally posted by vijayanto

hi friends,
i plan to get datas from two databases in sql query
and the two databases contain different tables
i want to the table datas from those two databases

regards
vijay



are you trying to combine the rows from both tables? in that case what you need is to create a view with UNION ALL query to join both databse tables data.
However if your effort is to join the fields from both tables into single resultset then what you need is a view with a join between them to get all columns in single resultset.
Go to Top of Page
   

- Advertisement -