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

How to check local and global angular versions

 Use the command ng version (or ng v ) to find the version of Angular CLI in the current folder. Run it outside of the Angular project, to f...