I often get request from blog reader for T-SQL script to rename database table column name or rename table itself.
The script for renaming any column :
SP_RENAME 'TableName.[OldColumnName]' , '[NewColumnName]', 'COLUMN'
The script for renaming any object (table, sp etc) :
SP_RENAME '[OldTableName]' , '[NewTableName]'
This article demonstrates two examples of renaming database object.
- Renaming database table column to new name.
- Renaming database table to new name.
In both the cases we will first see existing table. Rename the object. Test object again with new name.
1. Renaming database table column to new name.
Example uses AdventureWorks database. A small table with name “Table_ First” is created. Table has two fields ID and Name.

Now, to change the Column Name from “Name” to “NameChange” we can use command:
USE AdventureWorks
GO
sp_RENAME ‘Table_First.Name’, ‘NameChange’ , ‘COLUMN’
GO
Following Fig. show use of SP_RENAME Command

You can see the column name “Name” is now changed to “NameChange”.
USE AdventureWorks
GO
SELECT *
FROM Table_First
GO
Following fig. verify that the column name has been changed.
2.Renaming database table to new name.
We can change the table name too with the same command.
SP_RENAME ‘Table_First’, ‘Table_Last’
GO
Following fig. Shows how we can change Table Name.

Now, the table name “Table_First” is renamed as “Table_Last”.
“Table_First” will no longer be available in database. We can verify this by running script:
USE AdventureWorksSELECT *
GO
FROM Table_First
GO
The Messages shows an error “Invalid object name ‘Table_First’.”
To check that the new renamed table exist in database run script:
USE AdventureWorks
GO
SELECT *
FROM Table_Last
GO

You can see the same data now available in new table named “Table_Last”
Reference: Pinal Dave (http://www.SQLAuthority.com)






That is winning info!
Hi Pinal,
If we change the cloumn name, suppose if the column has a index on it, will the change of name effect the index already created.
hi,
This is use full info
If the column have a constraints how can rename the column
Thanks for the info.
Will u guide me how to alter existing constraint
Hi,
Yes if we have not null constraint in column we can able to change the column name.
Hi,
Thanks it works.
Hi Guys,
This is very Useful Information.Thank you.
without using Sp_Rename Stored procedure how can i
rename the table?
Is any other Query to do this?
[...] 2008 by pinaldave I have written many articles about renaming a tables, columns and procedures SQL SERVER - How to Rename a Column Name or Table Name, here I found something interesting about renaming the stored procedures and felt like sharing it [...]
Thank you for sharing. This is a great glob post. Great info and rendering (live the screens etc).
thnq very much sir………
Thank you sir for giving a valuable information
Thank you very much sir for giving a valuable information