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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Query help

Author  Topic 

sqlfresher2k7
Aged Yak Warrior

623 Posts

Posted - 2008-09-23 : 12:14:44
[code]

TableA
------
SID syr sdt
--- --- ----

I need a help for update query with below condition
if the sdt <=2006 then SID=4 and syr=2006
Else SID=5 and syr=2007

Thanks for your help in advance !!
[/code]

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-23 : 12:49:42
[code]UPDATE Table
SET SID =CASE WHEN sdt<=2006 THEN 4 ELSE 5 END,
syr=CASE WHEN sdt<=2006 THEN 2006 ELSE 2007 END[/code]

I assume sdt is of integer datatype.
Go to Top of Page

sqlfresher2k7
Aged Yak Warrior

623 Posts

Posted - 2008-09-23 : 13:47:15
Thanks !!
Go to Top of Page
   

- Advertisement -