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

Misc Javascript points

 Nodejs can support multithreading through use of promises _ is the numeric separator for javascript, that means the numbers 10_000, 11.23_0...