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
 Comparing Tables

Author  Topic 

ISBB
Starting Member

12 Posts

Posted - 2009-08-16 : 20:40:07
I have been reading about comparing tables but only find articles on tables of "LIKE" structure. This is the query im currently using however im still getting duplicate entries.

Purge Table only includes col: tl1, tl2 (phone numbers with and without dash's)
Source Tables have all the rest of the information. For some reason this query still gives me results with the purge # still in there. Any ideas on tweaking this to get everything out of it. If tl2 exists in the source table i dont want that row included in the results.

select top 25000 i.name,i.address,i.city,i.state,i.zip,i.tl2
from source.dbo.idearc i
left join purge.dbo.purge p on p.tl2 = i.tl2
and p.tl2 is null
where i.state = '"TN"'
ORDER BY newid();


Thanks for the help again fellas

Yep.. Point and Click dont work here..

EugeneLim11
Posting Yak Master

167 Posts

Posted - 2009-08-17 : 04:55:18
Is this what you want. Further elabouration may be required before we can get it right. Hope the below works for you.

select top 25000 i.name,i.address,i.city,i.state,i.zip,i.tl2
from source.dbo.idearc i
left join purge.dbo.purge p on p.tl2 = i.tl2
where i.state = '"TN"'
and i.tl2 is not null
and p.tl2 is null
ORDER BY newid()


check out my blog at http://www.aquariumlore.blogspot.com
Go to Top of Page

ISBB
Starting Member

12 Posts

Posted - 2009-08-17 : 14:22:48
Eugene thanks for the tip.. I will give that a try and see how it works out.

Thanks bud..

Yep.. Point and Click dont work here..
Go to Top of Page
   

- Advertisement -