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
 Script Library
 Large amount of data

Author  Topic 

jj7353
Starting Member

10 Posts

Posted - 2013-09-07 : 12:15:57
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

30421 Posts

Posted - 2013-09-07 : 15:26:04
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 - 2013-09-07 : 20:24:18
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
   

- Advertisement -