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 2008 Forums
 Transact-SQL (2008)
 Some Help Please

Author  Topic 

Alisha26
Starting Member

19 Posts

Posted - 2011-05-03 : 05:41:15
I have two tables
Table1 has 25 fields and Table2 has 30 fields.

I have to compare Table1 fields with Table 2 fields

What is the best or efficent way to do this.
(Iam actually writing query for both the table and exporting to an Excel and comparing values)

Is there any better way to do this?

Thanks



Alisha

lionofdezert
Aged Yak Warrior

885 Posts

Posted - 2011-05-03 : 05:48:49
SELECT column1,column2,column3 FROM Table1
EXCEPT
SELECT column1,column2,column3 FROM Table2
--use INTERSECT to return matching rows in both tables

--------------------------
http://connectsql.blogspot.com/
Go to Top of Page

Alisha26
Starting Member

19 Posts

Posted - 2011-05-03 : 05:56:22
Hey thanks is there any thing else we can do apart from both two keywords

Alisha
Go to Top of Page

lionofdezert
Aged Yak Warrior

885 Posts

Posted - 2011-05-03 : 06:05:26
What do you wanna do ELSE ???
If above mentioned EXCEPT/INTERSECT doesn't bring requried result then you must share your tables sturctures and expected output.
--------------------------
http://connectsql.blogspot.com/
Go to Top of Page
   

- Advertisement -