Quick one today:
Sometimes, we need to rename some column names. Surprisingly, there is no intuitive way to rename a column name in Sql Server i.e. ALTER TABLE statement type method. We need to use a system stored procedure called sp_rename.
Example Below:
The sample code below, renames the column ‘PKID’ in ‘dbo.ProductAttribute’ table to ‘ProductAttributesID’.
-- -- Rename Column -- EXEC sp_rename 'dbo.ProductAttributes.PKID', 'ProductAttributesID', 'COLUMN' GO
Hope this helps,
_Sqltimes