SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

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

jfm
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

3758 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
EXCEPT
SELECT col1,col2 FROM DB2.dbo.TableA;

SELECT col1,col2 FROM DB2.dbo.TableA
EXCEPT
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  
 New 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