In this article we will show you, How to write a SQL Query to Swap Column Values in SQL Server with example. This is one of the common SQL Interview Question that you might face in the interviews. For this example, We are going to use the below shown data
How to Swap Column Values in SQL Server?
Please use the below shown query to swap two column values in SQL Server.
-- Query to Swap Two Column Values in SQL Server
USE [SQL Tutorial]
SET [Education] = [Occupation],
[Occupation] = [Education]
Let me show you the updated records. From the below screenshot you can see that the information in Education column is stored in Occupation Column. And data inside the Occupation column is stored in Education column.
Thank You for Visiting Our Blog