T-Sql - rename a table or column name via stored procedure

Goal:

Rename a database table or column name using a t-sql stored procedure.

 

How to:

 

Rename a table:

EXEC sp_rename 'TableToBeRename', 'NewTableName'
 

Rename a column:

EXEC sp_rename
    @objname = 'TableNameColumnToBeRenamed,
    @newname = 'NewColumnName',
    @objtype = 'COLUMN'

Print | posted @ Monday, October 24, 2011 1:06 PM

Comments on this entry:

Gravatar # re: T-Sql - rename a table or column name via stored procedure
by Jorge Liguori at 2/2/2012 12:31 PM

how to rename a table adding the current date and time:

EXEC sp_rename wrkreservationairfare, wrkreservationairfare + ' ' + getdate()
Post A Comment
Title:
Name:
Email:
Comment:
Verification: