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
 Missing Records

Author  Topic 

divan
Posting Yak Master

153 Posts

Posted - 2013-02-04 : 16:06:35
I have created a temp file with all the agency_id that are in a policy file.. There are a lot more ageny_id in the agency file. Now I need to see which of the agency_id in the agency file are not in my temp file..

SELECT DISTINCT AGENCY_ID
INTO #TEMP1

FROM POLICY
WHERE POLICY_NUMBER NOT LIKE '%Q%' AND AGENCY_ID IS NOT NULL ORDER BY AGENCY_ID

any help will be very much appreciated..

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2013-02-04 : 16:33:03
by "file" I assume you mean TABLE, right?

select a.agency_id
from agency a
left outer join #temp1 t on t.agency_id = a.agency_id
where t.agency_id is null

Be One with the Optimizer
TG
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-02-04 : 22:50:09
[code]
select agency_id
from agency a
WHERE NOT EXISTS(SELECT 1 FROM #temp1 WHERE agency_id = t.agency_id)
[/code]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -