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.
Author |
Topic |
imranabdulaziz
Yak Posting Veteran
83 Posts |
Posted - 2011-02-25 : 00:26:03
|
Dear All,I am using sql server 2005.I have two table one is master and other is temp with same struncture given below.Now i need to valide that GIven Itemcode and BatchNo are same in both the table. if not match , Unmatch Itemcode and batchno put in to error tableI have following table structure LikeMaster TableItemName Itemcode BatchNoPencil abc 123Pencil efg 456Pencil mnk 789temp tableItemName Itemcode BatchNo srnoPencil abc 123 1Pencil efg 456 2Pencil mnk 789 3 |
|
MIK_2008
Master Smack Fu Yak Hacker
1054 Posts |
Posted - 2011-02-25 : 04:50:25
|
-- For Matching Rowsselect MT.ItemName,MT.ItemCode,MT.BatchNoFrom MasterTable MTInner Join TempTable TT on TT.ItemCode=MT.ItemCode and TT.BatchNo=MT.BatchNo--For Unmatch rowsselect MT.ItemName,MT.ItemCode,MT.BatchNoFrom MasterTable MTLeft Join TempTable TT on TT.ItemCode=MT.ItemCode and TT.BatchNo=MT.BatchNoWhere TT.ItemCode is nullCheersMIK |
 |
|
|
|
|