Description:
In this example we explain that how to Swap values
between two columns using SQL Server query. Or how to update column1 values to
column2 and column2 values to column1 like vice versa in sql server using
update statement.
As we all know that when we working with database moving,
swapping and updating values between a column is a common task for the all the
developer in IT industries because there is a routine work.
Here in the below example we have one table called test
in which there are two column column1 and column2 in which we have to swap the
data column1 to column2 and vice versa.
Below is the sql query to swap the data between two columns
in SQL Server.
Before Swapping :
DECLARE @temp as float
update Test
set @temp =
column1,
column1 =
column2,
column2 =
@temp
After Swapping :
0 comments:
Post a Comment