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 |
|
tfountain
Constraint Violating Yak Guru
491 Posts |
Posted - 2003-02-21 : 16:03:12
|
| Suppose I have a procedure as follows:CREATE PROCEDURE usp_MyTest(@ClientKey INT = NULL,@EmployeeKey INT = NULL)ASIF (@EmployeeKey IS NOT NULL)SELECT * FROM Table WHERE EmployeeKey = @EmployeeKeyELSESELECT * FROM Table WHERE ClientKey = @ClientKeyWhat are the performance implications (if any) of doing this? |
|
|
SamC
White Water Yakist
3467 Posts |
Posted - 2003-02-21 : 16:28:11
|
| The overhead of an IF statement to determine which SELECT to execute. I wonder if anyone can quantify this, but I'd say the performance implications are so small they are immeasurable.Sam |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2003-02-21 : 16:32:44
|
| I'd say that's probably faster than:SELECT * FROM Table WHERE EmployeeKey = @EmployeeKey OR ((@EmployeeKey IS NULL) AND (ClientKey = @ClientKey ))which I think would be the most efficient alternative done in 1 statement .... try them out!- Jeff |
 |
|
|
|
|
|