SQL case statement for updating multiple rows

Create table #temp  (

pid int,

name  varchar (50)

)

 

insert into #temp select 1,'a' union all

select 2,'b'

 

select * from #temp

 

UPDATE #temp

 

    SET name = CASE pid

        WHEN 1 THEN 'aa'

        WHEN 2 THEN 'bb'

       

    END

WHERE pid IN (1,2)

 Modify the  highlighted query  accordingly

 

-Shinu

Ebook Download
View all
Learn
View all