Sunday, April 28, 2013

How to exchange the data of column in the same table in the Sql server


1. Swap with the help of temporary variable:
-------------------------------------------------
DECLARE @temp AS varchar(10) UPDATE Employee1 SET @temp=LastName, LastName=FirstName, FirstName=@temp
 
 
2.directly:
------------

UPDATE Employee1 SET LastName=FirstName, FirstName=LastName

No comments:

Post a Comment