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
 Script Library
 Large amount of data
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

jj7353
Starting Member

10 Posts

Posted - 09/07/2013 :  12:15:57  Show Profile  Reply with Quote
table1 500+ records

ip | area | carid
1.1.1.1,dallas,car1
192.158.2.1,dallas,car1


table2 250+ records

ip | area
192.158.2.1,dallas,car1


I am trying to return the records in table1 where ip and area combo do not show up in table2. My query is taking way to long.

Hope that makes sense

Thank you

Johnny

John

SwePeso
Patron Saint of Lost Yaks

Sweden
30116 Posts

Posted - 09/07/2013 :  15:26:04  Show Profile  Visit SwePeso's Homepage  Reply with Quote
SELECT t1.*
FROM dbo.Table1 AS t1
WHERE NOT EXISTS (SELECT * FROM dbo.Table2 AS t2 WHERE t2.IP = t1.IP AND t2.Area = t1.Area);



Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA
Go to Top of Page

jj7353
Starting Member

10 Posts

Posted - 09/07/2013 :  20:24:18  Show Profile  Reply with Quote
Thank you; I did try that before. I also indexed both tables. ip area index. Its still taking a long time.

John
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