Home >> Software >> Tips and Tricks >> How Rename a Column or Table in SQL SERVER

How Rename a Column or Table in SQL SERVER

Updated: 07/14/2010 13:07 PM
Author: Shiju Kadamala

A table name can be changed by using sp_RENAME function

Transact-SQL Syntax :



Where 'object_type' is the type of object being renamed. object_type is varchar(13), with a default of NULL, and can be one of these values. The Values for 'object_type' are

Value Description
COLUMN A column to be renamed.
DATABASE
INDEX A user-defined index.
OBJECT An item of a type tracked in sys.objects. For example, OBJECT could be used to rename objects including constraints (CHECK, FOREIGN KEY, PRIMARY/UNIQUE KEY), user tables, and rules.
USERDATATYPE An alias data type or CLR User-defined Types added by executing CREATE TYPE or sp_addtype.


The script for renaming any object (database, table, sp etc) :





The script for renaming any column