Changing MS SQL Table Name with Query

To replace a table name with a query in MS SQL Server, the following procedure should be followed.

EXEC sp_rename {Old Table Name}, {New Table Name}

This is how it is used..

EXEC sp_rename 'OldTableName', 'NewTableName'

Note : When the relevant code runs, you will see that the table name has not changed in the left panel, Object Explorer. Therefore, the Tables folder in the database where the change is made should be Refresh.



You May Interest

How is Auditing Different From Change Data Capture in SQL Server?

What is an Index in SQL Server ?

Getting List of All Stored Procedures in Database in MS SQL

What is the Use of DBCC Commands in SQL Server ?

What is the Difference Between VARCHAR and VARCHAR(MAX) Datatypes ...