Here we will learn how to rename or change sql server table name using sp_rename statement or sql server management studio with examples.
To alter or rename or change name of table in SQL database we have two different methods one is using ”SP_RENAME” Query and another one is directly using SQL Server Management Studio
By using “SP_RENAME” statement we can change name of SQL Table. Generally to alter or rename / change table name in SQL our syntax will be like as shown below
Following is the syntax to rename table in sql server using sp_rename statement
SP_RENAME 'oldtablename', 'newtablename'
Here “oldtablename” means name of the present table and “newtablename” means its new name for table.
The following SQL statements will rename or change 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
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
Once we click on Rename option it will allow us to modify table name in that enter required table name. Once we change table name that will be like as shown below