Thursday, June 25, 2009

Rename an Existing Column of a Table in MS SQL

In SQL server , Renaming a existing column without any data loss is possible .
A Inbuild System Stored Proc is available for the same

EXEC sp_rename `tableName.[existingColumnName]`, `newColumnName`, `COLUMN`

EXEC sp_rename `tblShortName.[longName]`, `shortName`, `COLUMN`

The above SP on execution will change the column longName in the tblShortName table to shortName

Note :

Take care you make the changes in all the stored proc and function where you are refering the old Column to the new Column

1 comment:

  1. Today’s most accurate tip for stock
    BUY HINDALCO 120 PUT ABOVE 3.10 TG- 3.60/4.40/5.50 SL- 1.90
    Free option tips


Express you views