Rajanand Ilangovan
Rajanand Ilangovan

Rajanand Ilangovan

How to swap column value in SQL?

How to swap column value in SQL?

SQL interview questions and answers #7

Rajanand Ilangovan's photo
Rajanand Ilangovan
·Mar 30, 2022·

1 min read

Question:

Write an update statement to swap the column values without using a temporary tables. Before Update: image.png After Update: image.png

Answer:

UPDATE dbo.STUDENT
SET first_name = last_name,
    last_name = first_name;

swap column values in sql - rajanand.org.png

Impressum