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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2006-09-12 : 18:47:37
|
| Ken writes "a query that have a where clause ( UserID = @UserID OR @UserID IS NULL )the @UserID is being supply at the user level therefore it might and might not have a value pass through. The issues is that when the value pass through is NULL the query tense to scan the table indexes and eat up too much cpu. Any suggestion on how too correct this where clause? Basically I am trying to improve the database performance." |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2006-09-12 : 19:19:32
|
| If @UserID is NULL, SQL Server will have to scan the table because all rows will satisfy the criteria.If you don't want this, do not allow @UserID to be NULL or change your where clause.CODO ERGO SUM |
 |
|
|
|
|
|