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.
| Author |
Topic |
|
mk_garg20
Constraint Violating Yak Guru
343 Posts |
Posted - 2005-02-22 : 18:17:01
|
| Hi All,Here is my code[code]select resourceid into #tempfrom resource where resourceid<=5select resource.resourceid from resource Left join #temp on #temp.resourceid=resource.resourceidwhere #temp.resourceid is nulldrop table #temp[/Code]Is there any better way to do same this?Thanksmk_garg |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2005-02-22 : 18:28:39
|
Why can't you just do this:select resourceidfrom resourcewhere resourceid > 5 Tara |
 |
|
|
mk_garg20
Constraint Violating Yak Guru
343 Posts |
Posted - 2005-02-22 : 18:38:07
|
| You are right tara.I just modified my requirement so that i makes easy for you.Basically after some manipulation, i will be getting some resource ids in temp table.In next query i want to ignore those ids.I can rewrite it as [Code]select resourceid from resource where resourceid not in (select resurceid from #temp)[/Code]I dont want to use IN operator.Thanksmk_garg |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2005-02-22 : 18:42:44
|
| If you don't want to use IN, then LEFT OUTER JOIN is the way to go. But instead of just saying I don't want to use IN, I would test the performance difference between the two. select resourceid from resource where resourceid not in (select resurceid from #temp)select resource.resourceid from resource Left join #temp on #temp.resourceid=resource.resourceidwhere #temp.resourceid is nullTara |
 |
|
|
mk_garg20
Constraint Violating Yak Guru
343 Posts |
Posted - 2005-02-22 : 19:02:35
|
| Hi Tara,I checked it.Left Join is faster than IN operator.Thanksmk_garg |
 |
|
|
|
|
|