1. Swap with the help of temporary variable:
DECLARE @temp AS varchar(10)
UPDATE Employee1 SET @temp=LastName, LastName=FirstName, FirstName=@temp
The resulting table can be verified.
UPDATE Employee1 SET LastName=FirstName, FirstName=LastName
This query can also swap the column data.
Now we can see the difference by :
Select ID,FirstName, LastName from Employee
This swapping be done for more than two columns also. Suppose we need to swap three columns named value1,value2,value3
UPDATE Employee SET value1=value3, value2=value1, value3=value2
So like this we can swap column data. Hope freshers will find it helpful . : )