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
 not in
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

divan
Posting Yak Master

153 Posts

Posted - 06/24/2013 :  10:56:51  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

Pakistan
1054 Posts

Posted - 06/24/2013 :  11:02:21  Show Profile  Reply with Quote
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

India
95 Posts

Posted - 06/24/2013 :  11:31:05  Show Profile  Reply with Quote
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
  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.06 seconds. Powered By: Snitz Forums 2000