Monday, May 30, 2011

How to swap to values in a table ? e.g. 'M' with 'F'



/* APPROACH 1 */
update test set gender = (case when gender = 'M' then 'F' when gender = 'M' then 'F' end )/* APPROACH 2 */
declare @oldvalue varchar(10) = 'M'declare @newvalue varchar(10) = 'F'update test set gender = (case when gender = @oldvalue then @newvalue when gender = @newvalue then @oldvalue 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...