---
title: "How to Swap the values of two columns in SQL Server."  
description: "How to Swap the values of two columns in SQL Server."  
author: "Anonymous User"  
published: 2016-03-03  
updated: 2016-03-03  
canonical: https://www.mindstick.com/forum/34027/how-to-swap-the-values-of-two-columns-in-sql-server  
category: "mssql server"  
tags: ["sql server"]  
reading_time: 1 minute  

---

# How to Swap the values of two columns in SQL Server.

We want to [Swap the values](https://www.mindstick.com/forum/158951/how-to-swap-the-values-of-two-variables-without-using-a-temporary-variable-in-python) of two [columns in SQL](https://www.mindstick.com/forum/161180/how-to-compare-rows-and-columns-in-sql-server-database) Server. How to do this please Help me.

## Replies

### Reply by Anonymous User

When you want to [swap](https://www.mindstick.com/interview/23038/how-to-swap-of-two-number-without-using-3rd-or-temp-variable) the [values](https://www.mindstick.com/forum/327/sum-textbox-values) of two columns of a table in [SQL Server](https://www.mindstick.com/articles/12999/what-is-table-valued-function-in-sql-server), how could you achieve this tricky task?.

it is simple like code below.

```
 CREATE TABLE [dbo].[Employee] (    [EmpNo]       INT  IDENTITY (1, 1) NOT NULL,    [EmpName]     VARCHAR (50) NOT NULL,    [Salary]      DECIMAL (18) NOT NULL,    [DeptName]    VARCHAR (50) NOT NULL,    [Designation] VARCHAR (50) NOT NULL,    PRIMARY KEY CLUSTERED ([EmpNo] ASC));
select * from [Employee]  
update Employee set Designation=DeptName,DeptName=Designation select * from [Employee]   
```


---

Original Source: https://www.mindstick.com/forum/34027/how-to-swap-the-values-of-two-columns-in-sql-server

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
