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)
 How to merge into single statement

Author  Topic 

Delinda
Constraint Violating Yak Guru

315 Posts

Posted - 2010-04-07 : 05:52:41
I've as follow,
update t1 set a = 5 where b =7
update t1 set a = 13 where b =4
update t1 set a = 1 where b =6
update t1 set a = 5 where b =9


It's possible above statement merged into single statement? If possible, how it's look's like?

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-04-07 : 05:54:51
[code]
update t1
set a = case b
when 4 then 13
when 6 then 1
when 7 then 5
when 9 then 5
end
where b in (4, 6, 7, 9)
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

Delinda
Constraint Violating Yak Guru

315 Posts

Posted - 2010-04-07 : 06:01:26
tq sir
Go to Top of Page
   

- Advertisement -