Sunday, December 30, 2012

How to Rename Column in Sql Server Table


sp_RENAME 'tblAccount.AccountNO', 'AccountNO1' , 'COLUMN'

To perform the operation we use the inbuilt stored procedure sp_RENAME.

tblAccount - Table name.
AccountNO - Current column name.
AccountNO1 - Rename column to AccountNO1

After you have execute the query you'll get the below message.
"Caution: Changing any part of an object name could break scripts and stored procedures."

This message is just to inform you that if you have already used the column name in any other sql queries the change will affect them so remember to change the column name if you have used it any sql query.

No comments:
Write comments
Recommended Posts × +