In this article, we will show you how to write a query to Swap Column Values in SQL Server with example. For this SQL Swap Column Values Interview Question, We are going to use the below-shown data
How to Swap Column Values in SQL Server?
Please use the below-shown frequent query to swap two column values.
UPDATE [dbo].[EmployeeDuplicates] SET [Education] = [Occupation], [Occupation] = [Education] GO
Messages -------- (14 row(s) affected)
Let me show you the updated SQL Server records. From the below screenshot, you can see that the information in the Education column stored in Occupation Column. And data inside the Occupation column is stored in the Education column.