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
 General SQL Server Forums
 New to SQL Server Programming
 not in

Author  Topic 

divan
Posting Yak Master

153 Posts

Posted - 2013-06-24 : 10:56:51
I have a table TAIL with the following records

policy_number prem
cc 10063 1000
cc 10063 10050
cc 10063 10034
cc 10063 1005

I have another table DETAIL

POLICY PREM
CC 10063 1000
CC 10063 10050
CC 10063 10034
CC 10063 1005
CC 10063 100500

I need a script that will show me the records that are in DETAIL but not in TAIL

Please help

Thanks

MIK_2008
Master Smack Fu Yak Hacker

1054 Posts

Posted - 2013-06-24 : 11:02:21
SELECT A.Policy_number,B.Policy_number
FROM Detail A
Left Join Tail B on A.policy_number=B.Policy_Number --Considering that its the Policy_Number through which the tables are joined
WHERE B.Policy_Number IS NULL

Cheers
MIK
Go to Top of Page

mmkrishna1919
Yak Posting Veteran

95 Posts

Posted - 2013-06-24 : 11:31:05
Hi Divan,

If your are trying to compare all columns of both tables then then try this?

Records that are in detail not there in tail..
select policy_num,perm from detail
except
select policy_num,perm from tail

Records that are in tail not there in detail..

select policy_num,perm from tail
except
select policy_num,perm from detail

thanks..

M.MURALI kRISHNA
Go to Top of Page
   

- Advertisement -