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)
 Multiple Update

Author  Topic 

danasegarane76
Posting Yak Master

242 Posts

Posted - 2007-11-10 : 00:30:48
Hi all,
I am having one table with these structure
Empid
Name
Age
Managerid
DeptId
Salary
Sex


I want to update the salary of the Employee like if the Employee is 'M' then increase it 20% and if Femlale('F') then 10%. I am trying like this. But it is not working

update Employee ,Case Sex
when 'M' then Salary=Salary*1.20
when 'F' then Salary=Salary*1.10
Else Salary
End


Thanks in Advance
Dana

Vinnie881
Master Smack Fu Yak Hacker

1231 Posts

Posted - 2007-11-10 : 00:51:01
[code]
Update Employee
set Salery = case Sex
when 'M' then Salary*1.20
when 'F' then Salary*1.10
Else Salary
End
[/code]
Go to Top of Page

danasegarane76
Posting Yak Master

242 Posts

Posted - 2007-11-10 : 01:05:03
Thanks Vinnie,
Its working :)
Dana
Go to Top of Page
   

- Advertisement -