How To Change Column Name In SQL Server

Recently, I had the opportunity to work on an important table where I just needed to rename a few columns. Though it looks so simple, since it was a production environment, I was a little careful while doing this. The first thing I did was take a proper backup, and then I followed one of the possible approaches below to rename the column.

Here, we will discuss four simple approaches to doing this. Let us discuss this topic with an example.

Approach-1: Using the basic Rename option

1. Right-click on the column name and select the Rename option.

How to change column name in SQL Server

2. Enter the new name and then press the enter key.

how to change column name in existing table in sql server

The column has been renamed successfully, as shown in the screenshot below.

how to change column name in sql server management studio

Check out How To Rename The Table Name In SQL Server

Approach-2: Just click on the column name

1. Click on the column name or slow double-click on it. The column name will now be in editable mode, as shown in the screenshot below.

How to change column name in SQL Server

2. Enter the new name and then press the Enter button.

how to rename column name in sql server

3. Click the Yes button to confirm the rename operation, as shown in the screenshot below.

how to rename column name in sql server using query

Now, the column has been renamed successfully, as shown below.

how to rename the column in sql server

Check out Create table if not exists SQL Server

Approach-3: Using the Design window

1. Right-click on the table name and select the Design option.

how to change the column name in sql server

2. Enter the new name for the column you wish to rename, then click the Save button.

how to change a column name in sql server

Now, the column’s name has been changed successfully, as shown in the screenshot below.

how to change table column name in sql server

Check Out How To Copy One Table To Another In SQL Server

Approach-4: Using the sp_rename stored procedure

Using the query below, we can also use the sp_rename stored procedure to rename the column.

EXEC sp_rename 'Vehicle.VehicleQuality', 'VehicleTested', 'COLUMN';

After executing the above query, I got the expected output, and the column name changed successfully, as shown in the screenshot below.

change column name in sql server query
how to change column name in sql server using query

Conclusion

While renaming columns is relatively simple, the real challenge is managing the change across your entire database. Database administrators and developers must approach column renaming as not just an immediate change. Still, they should ensure it’s synced with the whole database and not breaking any existing functionality.

You may also like following the articles below