SQL Alter (Rename) Table Statement

In sql, we can alter or rename or change the name of table in sql database either by using ”SP_RENAME” query or by using SQL Server Management Studio.

SQL ALTER Table using Query

In sql, by using “SP_RENAME” statement we can change the name of Table in database based on our requirements.

SQL ALTER Table using Query Syntax

Following is the syntax of alter or rename the table in sql server using sp_rename statement

 

SP_RENAME 'oldtablename', 'newtablename'

Here “oldtablename” is the name of the present table and “newtablename” is the new name for table.

SQL ALTER Table using Query Example

Following is the example query to change or rename the table name from “EmployeeDetails” to “EmployeeInformation”.

 

SP_RENAME 'EmployeeDetails', 'EmployeeInformation'

Now refresh your sql database section and check for table with new name that would be like as shown below.

 

After changing or renaming table name in sql server

ALTER Table using SQL Server Management Studio

To change table name open SQL Server Management Studio à Select your database in Databases section à Go to Tables Section à Select your table à Right click and Select Rename Table like as shown below.

 

Rename table in SQL Server using Management Studio

Once we click on Rename option, it will allow us to modify a table name in that enter a required table name. Once we change the table name that will be like as shown below.

 

After changing or renaming table name in sql server