SQL Rename Table

How to Rename Table in SQL Server with an example?. To demonstrate the Rename Table name, we use the below-shown Customer table.

SQL Rename Table 1

SQL Rename Table Name Example

There is a stored procedure called SP_RENAME to rename the table name. In this example, we will rename the Customer table using this sp. The syntax to rename table name using sp_rename

-- Syntax for SQL Server rename table Name is: 
SP_RENAME '[Old Table Name]', '[New Table Name]'

We use the above sp_rename syntax to rename the Customers table to NewCustomers

SQL Rename Table 2
SQL Rename Table 3

Rename Table using SSMS

If you can access Management Studio, double-click on the SQL Server Table allows you to change the table name. Let me change the table name to CustomersTable

SQL Rename Table 5

Rename Table Name Approach 2

To rename a table in SQL Server, within the Object Explorer, Go to the Database where the table exists. Next, Right-click on the Table, and select the Rename from the context menu.

SQL Rename Table 7

We are changing the table name to Customers and you can see the new table name.

SQL Rename Table 9