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 EXISTS

Author  Topic 

divan
Posting Yak Master

153 Posts

Posted - 2013-10-23 : 11:16:25
Good Morning

I have two tables POLICY and REGISTER with POLICY_DATE_TIME in both tables.. They both have to have matching records with the same POLICY_DATE_TIME but due to some errors the register table is missing records that do not have the same POLICY_DATE_TIME as the policy table..

I would like your help in trying to use the not exists command to find out the policy records that do not have matching POLICY_DATE_TIME in the register table..

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-10-23 : 11:22:19
[code]SELECT
*
FROM
Policy p
WHERE
NOT EXISTS
(
SELECT * FROM Register r
WHERE r.policy_date_time = p.policy_date_time
-- feels like you need something else, perhaps polic number
-- and r.policy_number = p.policy_number
)[/code]
Go to Top of Page

divan
Posting Yak Master

153 Posts

Posted - 2013-10-23 : 14:33:10
Thanks
Go to Top of Page
   

- Advertisement -