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)
 Updating two Variables

Author  Topic 

nvakeel
Yak Posting Veteran

52 Posts

Posted - 2008-02-11 : 10:24:25
I have two variables being updated with same field and on same condition. Like
Update x = Case @Y > 0 then 3 else 4
Update Z = Case When @Y>0 then 3 else 4

is there any other simple process to do this.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-02-11 : 10:29:35
[code]UPDATE Table1
SET X = CASE WHEN @Y > 0 THEN 3 ELSE 4 END,
Z = CASE WHEN @Y > 0 THEN 3 ELSE 4 END[/code]


E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

nvakeel
Yak Posting Veteran

52 Posts

Posted - 2008-02-11 : 11:11:38
thanks.
Go to Top of Page
   

- Advertisement -