![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Which is most preferable between the below SQLs? In terms of consuming resources or fast execution. 1. Update Table1 set Reason = 'SX#' where (Sex <> 'M' or Sex <> 'F' or trim(Sex) <> '') and Key = inKey And Sub_Key = inSubKey and Reason is NULL; 2. Update Table1 set Reason = 'SX#' where (Sex not in ( 'M', 'F','') and Key = inKey And Sub_Key = inSubKey and Reason is NULL; I am calling this SQL in the stored procedure. If there is another better way of writing SQL for the above query, please let me know. Thanks in advance. Amrith |
#3
| |||
| |||
|
|
On Feb 8, 8:51 am, Amritha.Da... (AT) gmail (DOT) com wrote: Which is most preferable between the below SQLs? In terms of consuming resources or fast execution. 1. Update Table1 set Reason = 'SX#' where (Sex <> 'M' or Sex <> 'F' or trim(Sex) <> '') and Key = inKey And Sub_Key = inSubKey and Reason is NULL; 2. Update Table1 set Reason = 'SX#' where (Sex not in ( 'M', 'F','') and Key = inKey And Sub_Key = inSubKey and Reason is NULL; I am calling this SQL in the stored procedure. If there is another better way of writing SQL for the above query, please let me know. Thanks in advance. Amrith Sorry. If I use 'and' instead of 'or which query is efficient? 1. Update Table1 set Reason = 'SX#' where (Sex <> 'M' and Sex <> 'F' and trim(Sex) <> '') and Key = inKey And Sub_Key = inSubKey and Reason is NULL; 2. Update Table1 set Reason = 'SX#' where Sex not in ( 'M', 'F','') and Key = inKey And Sub_Key = inSubKey and Reason is NULL; Thanks! |
![]() |
| Thread Tools | |
| Display Modes | |
| |