Swap 2 Column Values in SQL Sever

Introduction

I have a table Employee as in the following.

SELECT * FROM EMPLOYEE

select query

Image 1.

Now I want to swap the Name Column value with Designation and the Designation column value with the Name column.

Write the following query.

UPDATE Employee SET Name=Designation , Designation=Name

Designation

Image 2.

Now write the select query again as in the following.

SELECT * FROM EMPLOYEE

name

Image 3.


Similar Articles