Thursday, April 7, 2011

CASE in UPDATE : How will change M to F in a table ?

create
id
gender
)
 
table test ( int identity(1,1) , nvarchar(10)insert test( gender) values (
 
'M') , ('F') , ('F') , ('M') , ('M') , ('F') insert test( gender) select 'M' union all select 'F' union all select 'M' union all select 'M' union all select 'F' union all select
 
'F' select * into test1 from test select a.id ,a.gender , b.gender from test a join test1 b on a.id = b.id update test set gender = case
when gender = 'M' then 'F' else 'M'end

No comments:

Post a Comment

 using Microsoft.AspNetCore.Mvc; using System.Xml.Linq; using System.Xml.XPath; //<table class="common-table medium js-table js-stre...