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)
 Can we use case in update query.

Author  Topic 

satish.gorijala
Posting Yak Master

182 Posts

Posted - 2009-07-14 : 02:44:29
Hi Can any one give an example of update query using case. i tried but getting error

Update Test set Code = case when Code = 1 then 'A'
When Code = 2 then 'B' when Code = 3 then 'c'

is it right? if not plz can you provide correct one

G. Satish

waterduck
Aged Yak Warrior

982 Posts

Posted - 2009-07-14 : 03:00:52
[code]Update Test set Code = case when Code = 1 then 'A'
When Code = 2 then 'B' when Code = 3 then 'c'end[/code]


Hope can help...but advise to wait pros with confirmation...
Go to Top of Page

satish.gorijala
Posting Yak Master

182 Posts

Posted - 2009-07-14 : 03:32:38
Thank you.

G. Satish
Go to Top of Page

waterduck
Aged Yak Warrior

982 Posts

Posted - 2009-07-14 : 03:52:33
welcome ^^ lets learn sql togther


Hope can help...but advise to wait pros with confirmation...
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-07-14 : 13:45:28
i assume the above statement was for example purpose as you cant assign string values to integer field Code (i see you've used Code=1,2...)
Go to Top of Page
   

- Advertisement -