Rename a Column Name or Table Name , Stored Procedure name in MS SQL server

Rename database table column to new name, Instead of using Alter command, we need to sp_rename in-built function in MS SQL Server. SP_Rename can be use for renaming either column name, table name or any object like stored procedure or functions.

Rename column name:-

SP_Rename  '[TableName].[ExistingColumnName]' , 'NewColumnName', 'Column'

Rename table name:-

SP_Rename 'ExistingTableName' , 'NewTableName'

Using similar way, we can change Stored Procedure name also

Rename Stored Procedure name:-
SP_Rename 'ExistingStoredProcedureName' , 'NewStoredProcedureName'


Caution: Changing any part of an object name could break scripts and stored procedures.

When you will execute these command then you will get the above warning message, don't worry about it but if you used column/table/stored procedure name reference used anywhere in you code or in database programming, please remember to update latest name in all places



Related Alrticles

Add Your Business in Free Listing

FREE!!! Registration