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
 How to compare data from 2 diff column and table
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Ismee
Starting Member

2 Posts

Posted - 12/06/2012 :  10:09:17  Show Profile  Reply with Quote
1. Table A colum Z
2. Table H column Y from anothe db
Data from 1. will be inserted into 2.
I need to check if all data from 1. are inserted into 2. Successfully.
Not only verify the records.but the data. Like data has abcd1234 then it should also inserted into 2. exactly
Sorry that I am rookie in SQL query. Can it be done via query and return true/ false result? And pointing which data is not inserted if false?

shilpash
Yak Posting Veteran

90 Posts

Posted - 12/06/2012 :  10:16:36  Show Profile  Reply with Quote
select COLUMNZ FROM TABLEA
EXCEPT
SELECT COLUMNY FROM TABLEH

IF YOU SEE 0 RECORDS,IT MEANS ALL DATAS ARE SAME,,IF ANY ROWS, THEN DATA FOR THAT ROW IS DIFFERENT.

Edited by - shilpash on 12/06/2012 10:17:48
Go to Top of Page

Ismee
Starting Member

2 Posts

Posted - 12/06/2012 :  19:47:15  Show Profile  Reply with Quote
Thanks.
How do I compare when the table is located at different db?
Can I use multiple except to compare more than 2 table?
Go to Top of Page

sodeep
Flowing Fount of Yak Knowledge

USA
7174 Posts

Posted - 12/06/2012 :  21:00:16  Show Profile  Reply with Quote
select COLUMNZ FROM DBNAME.dbo.TABLEA
EXCEPT 
SELECT COLUMNY FROM DBNAME.dbo.TABLEH
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.05 seconds. Powered By: Snitz Forums 2000