Saturday, 26 August 2023

SQL Part-2 : How to swap two column values​​ in same table ?

 Note :  All questions are related to SQL Server.

(1) In SQL : How to swap two column values​​ ?










Ans : 
update #tempSwap set EMPNAME = DEPT, DEPT = EMPNAME;

NOTE : I used temptable for demo purpose.
Assume I have to perform operation on Employee table then query will be 

update Employee set EMPNAME = DEPT, DEPT = EMPNAME;
















No comments:

Post a Comment