How to Rename database table column in sqlserver

you can rename a table in SQL Server 2005,2008 and 2012 by using SQL Server Management Studio or Transact-SQL.

Renaming a table will not automatically rename references to that table. You must manually modify any objects that reference the renamed table. For example, if you rename a table and that table is referenced in a trigger, you must modify the trigger to reflect the new table name.

Here i am describe all the ways to rename a table databse and column.

1-Rename Database:

1-sp_renameDB 'oldDB','newDB'

2-ALTER DATABASE Test MODIFY NAME = NewTest

2-Rename column name

Now, we see how to change the Column Name the below script will change table column name from “OldName” to “NewNameChange

USE yourdatabasename
GO
sp_RENAME 'TableName.OldName', 'NewNameChange' , 'COLUMN'
GO:

3.Renaming database table to new name.
We can also change the table name too with using the same command.

sp_RENAME 'oldname', 'newname'
GO


To rename a table
  1. In Object Explorer, right-click the table you want to rename and choose Design from the shortcut menu.
  2. From the View menu, choose Properties.
  3. In the field for the Name value in the Properties window, type a new name for the table.
  4. To cancel this action, press the ESC key before leaving this field.
  5. From the File menu choose Save table name.
Tags: , ,

Join Us!