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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 select query

Author  Topic 

gangadhara.ms
Aged Yak Warrior

549 Posts

Posted - 2010-01-25 : 05:54:21


How to find out any records in rvu_2009 table that is not in rvu_2010_target table ?? (not the other way)

Thanks,
Gangadhar

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2010-01-25 : 06:04:48
You can use a number of techniques. The overall best performance is to use EXISTS.
See http://weblogs.sqlteam.com/peterl/archive/2009/06/12/Timings-of-different-techniques-for-finding-missing-records.aspx



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-01-25 : 06:10:01
[code]
SELECT Col1, Col2, ...
FROM rvu_2009 AS T1
WHERE NOT EXISTS (SELECT * FROM rvu_2010_target AS T2 WHERE T2.SomeID = T1.SomeID)
[/code]
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-01-25 : 08:59:35
quote:
Originally posted by Kristen


SELECT Col1, Col2, ...
FROM rvu_2009 AS T1
WHERE NOT EXISTS (SELECT * FROM rvu_2010_target AS T2 WHERE T2.SomeID = T1.SomeID)




Didn't you see Peso's reply when posting?
The method is specified there too

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-01-25 : 09:52:46
Was writing whilst Peso was posting
Go to Top of Page
   

- Advertisement -