Monday, March 12, 2018

Rename a Column Name - SQL Sever

Recently I had a requirement to change the old table column name. therefore I needed a query to execute and rename column name. Following simple query script help me to fix it.

Script for Rename any column

SP_RENAME  'TableName.OldColumnName','NewColumnName','Column'

E.g.

USE [DataBase]
GO

SP_RENAME  'LKP_Item_Rate.Item','ItemRate','Column'

GO

Query is useful. when we have lot of data in the table and we needed to change the table columns without drop it.

No comments:

Post a Comment