Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Cross databases
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Posting Yak Master

145 Posts

Posted - 03/01/2013 :  07:06:39  Show Profile  Reply with Quote
Hi there guys,

I have DB1 and DB2 (2 different Databases)

I need to double-check which info I'm missing in DB2. So I will need to cross the tables using Col1 and Col2 from each table.

Any idea?

thanks !!

James K
Flowing Fount of Yak Knowledge

3873 Posts

Posted - 03/01/2013 :  07:32:55  Show Profile  Reply with Quote
Assuming they are on the same server, you could do any of the methods that people use to compare data in two tables - for example:
SELECT col1,col2 FROM DB1.dbo.TableA
SELECT col1,col2 FROM DB2.dbo.TableA;

SELECT col1,col2 FROM DB2.dbo.TableA
SELECT col1,col2 FROM DB1.dbo.TableA;
If you have a number of tables and columns, it is possible to use INFORMATION_SCHEMA.TABLES and INFORMATION_SCHEMA.COLUMNS to generate the list of tables and columns and construct the queries patterned after the above query.
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000