Doubts
hi
in sql server2005
i am using query in 1st method
(insert into <destinationtable>(no,name)
select a.no,a.name from <sourcetable> a left outer join <destination table> b on a.no=b.no where b.no is null)
2nd method
(insert into <destinationtable>(no,name)
select * from <sourcetable> except <destination table>
Both methods are executing Please tell me which method is executing fast and good performance method tell me reasons..
Thanks
Ram
August 13th, 2012 8:33am
Hi Ram,
EXCEPT is not optimized to perform like a join. it's the same as doing thing as you dumping your first query into a temp table and then deleting any rows that match the second
query. A properly written join or sub-select could do this more efficiently.
Also remember that with EXCEPT both queries have to have the same columns and all columns will be compared
Free Windows Admin Tool Kit Click here and download it now
August 13th, 2012 8:40am
Hi Ram,
EXCEPT is not optimized to perform like a join. it's the same as doing thing as you dumping your first query into a temp table and then deleting any rows that match the second
query. A properly written join or sub-select could do this more efficiently.
Also remember that with EXCEPT both queries have to have the same columns and all columns will be compared
August 13th, 2012 8:44am
you can also try NOT EXISTS
http://stackoverflow.com/questions/1662902/when-to-use-except-as-opposed-to-not-exists-in-transact-sqlhttp://www.rad.pasfu.com
Free Windows Admin Tool Kit Click here and download it now
August 13th, 2012 5:03pm
Suggest to go with join query.Please click the Mark as Answer or Vote As Helpful if a post solves your problem or is helpful!
August 13th, 2012 5:25pm