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 |
|
nirene
Yak Posting Veteran
98 Posts |
Posted - 2011-02-05 : 04:54:16
|
| Hello All,I use SQL Server 2005 and in which I use this query Select * from XTbl Where Loccode+Glcode+Slcode Not In (Select Loccode+Glcode+Slcode from YTbl) which cause my server to slow down, so pls advice me a best query with good retrival and performance.Nirene |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2011-02-05 : 05:13:31
|
SELECT x.* FROM xTbl AS xWHERE NOT EXISTS (SELECT * FROM yTbl WHERE y.LocCode = x.LocCode AND y.glCode = x.glCode AND y.slCode = x.slCode)Make sure you have an index on yTbl which cover all three columns; LocCode, glCode and slCode.Make sure you have an index on xTbl which has these three key columns; LocCode, glCode and slCode, and INCLUDE the rest of the columns from xTbl you want returned. N 56°04'39.26"E 12°55'05.63" |
 |
|
|
nirene
Yak Posting Veteran
98 Posts |
Posted - 2011-02-05 : 05:57:48
|
| Thank for your reply.And one more question both the table are table variable can a index be created on this.Nirene |
 |
|
|
|
|
|