Rename Table In SQL Server 2008
In this article we will see how to rename a table using in-built stored procedure.
In this article you will learn how to rename a database table.
Create Table
use person
create table emp
(
id int,
name varchar(5)
)
insert into emp values(1,'Aman')
insert into emp values(2,'Rahul')
select * from emp
Output:
Rename table emp to Employee.
To rename a table, SSMS has system stored procedure sp_rename which modifies the name of an existing table and column name or any other existing database object like view or stored procedure.
Syntax
sp_RENAME 'Table_First', 'Table_Last'
GO
Example:
Now Table emp i.e. old name. See it will give an error, because emp table is renamed to Employee.
Now select table Employee.
use person
select * from Employee
Output: