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 2005 Forums
 Transact-SQL (2005)
 help needed for update

Author  Topic 

zakeer
Starting Member

20 Posts

Posted - 2008-03-31 : 13:33:43
I have a table called emp

1 eno ename desg sal

1 aaa manager 20000
2 bbb executive 15000
3 ccc hr 25000
4 ddd ceo 45000


using single update statement , how can i update the salary based on the desg .i have to give hike if its manager sal =sal+(sal*0.10) .like this


Thanks & Regards
Zakeer

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-03-31 : 13:36:25
[code]UPDATE emp
SET sal=CASE WHEN desg='manager' THEN sal+(sal * 0.1)
WHEN desg='executive' THEN...
....
END[/code]
Go to Top of Page

zakeer
Starting Member

20 Posts

Posted - 2008-03-31 : 14:03:24
THANKS ALOT

Thanks & Regards
Zakeer
Go to Top of Page
   

- Advertisement -