Home » SQL » How to Rename Tables in SQL

How to Rename Tables in SQL

In this article, you will learn how to rename tables in SQL using two different method, First using command line and second using SSMS with example.

Rename tables in SQL using Transact SQL

SQL query does not have any statement that can directly rename any table. However, there is a stored procedure named sp_rename that allows you to change the name of a tables in SQL.

Below syntax you can use to change the name of the tables.

Syntax:

EXEC sp_rename 'old_table_name', 'new_table_name'

Example #1: Using Transact SQL

Lets take table “Table_Customer_Delivery” exist in ProductInfo database, as shown below image

rename tables sql

lets use stored procedure Command to rename above table

EXEC sp_rename 'Table_Customer_Delivery', 'Delivery_Table'

Once you will run above command the SQL Server returns the following below message:

rename tables

However, it will rename the table successfully.

After run the above command the new table will look like as shown below image

rename tables sql

Rename Tables using SSMS

Second method you can also rename tables in SQL using SSMS (SQL Server Management Studio), by simple right click on table in right side Panel of SQL Management Studio.

Option1:

Let tabel example to explain how to rename the Customer_Data table to Customer_Info

First, right-click on the table name and choose Rename option, it will allow you to type new name in left side panel window,

After change the name manually the table appear as shown below image with new name Customer_Info

Option2:

In option2 you have to only need to click on table name in left side of window panel, it will automatically allow you to rename the table name as shown below image.