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

divan
Posting Yak Master

153 Posts

Posted - 02/04/2013 :  16:06:35  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

USA
6059 Posts

Posted - 02/04/2013 :  16:33:03  Show Profile  Reply with Quote
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

India
52309 Posts

Posted - 02/04/2013 :  22:50:09  Show Profile  Reply with Quote

select agency_id
from agency a
WHERE NOT EXISTS(SELECT 1 FROM #temp1 WHERE agency_id = t.agency_id)


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

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.05 seconds. Powered By: Snitz Forums 2000