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 |
|
nishita_s
Yak Posting Veteran
61 Posts |
Posted - 2009-02-23 : 23:34:18
|
| UPDATE SavingsRegister SET FK_SKSOL_ClientID=Clients.UniqueID FROM SavingsRegister WITH(NOLOCK) INNER JOIN Clients WITH(NOLOCK) ON SavingsRegister.ClientID=Clients.ClientID WHERE RecordStatus <> 'O' OR RecordStatus <> 'D'i have lot of data in savingsledger table.i need to update this table. in where clause i m usingRecordStatus not in( 'O' , 'D')is it better than following statement?RecordStatus <> 'O' OR RecordStatus <> 'D' |
|
|
raky
Aged Yak Warrior
767 Posts |
Posted - 2009-02-23 : 23:44:14
|
| I think both are equal in performance |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-02-23 : 23:50:40
|
| hi nishita,it is better to use <> only because in some cases, not in will fails r use not exists than not in (performance is more for exists than in) |
 |
|
|
nishita_s
Yak Posting Veteran
61 Posts |
Posted - 2009-02-24 : 00:28:07
|
| hi bklrHow to use not exists in following statementUPDATE SavingsRegister SET FK_SKSOL_ClientID=Clients.UniqueIDFROM SavingsRegister WITH(NOLOCK)INNER JOIN Clients WITH(NOLOCK) ON SavingsRegister.ClientID=Clients.ClientIDWHERE RecordStatus <> 'O' OR RecordStatus <> 'D' |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-02-24 : 01:11:33
|
| try like thisUPDATE SavingsRegister SET FK_SKSOL_ClientID=Clients.UniqueIDFROM SavingsRegister WITH(NOLOCK)INNER JOIN Clients WITH(NOLOCK) ON SavingsRegister.ClientID=Clients.ClientIDWHERE NOT EXISTS (SELECT * FROM tablename where RecordStatus = 'O' OR RecordStatus = 'D') |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-02-24 : 01:18:49
|
quote: WHERE RecordStatus <> 'O' OR RecordStatus <> 'D'
NOTE: not OR not on the same column is ALWAYS true! No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
nishita_s
Yak Posting Veteran
61 Posts |
Posted - 2009-02-24 : 02:03:52
|
| Yes Webfrd, u r right. i m mistaken. there should be and not orhi bklr RecordStatus = 'O' and RecordStatus = 'D' this condition is on the same table which i m updattinglike UPDATE SavingsRegister SET FK_SKSOL_ClientID=Clients.UniqueIDFROM SavingsRegister WITH(NOLOCK)INNER JOIN Clients WITH(NOLOCK) ON SavingsRegister.ClientID=Clients.ClientIDwhere recordstatus<> 'O' and Recordstatus<>'D'so i just want to chk not in ('O','D') n instead of not in want to use not exists |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-02-24 : 10:32:28
|
| which table contains recordstatus column? |
 |
|
|
|
|
|