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:
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
- In Object Explorer, right-click the table you want to
rename and choose Design from the shortcut menu.
- From the View menu,
choose Properties.
- In the field for the Name value
in the Properties window, type a new name for the table.
- To cancel this action, press the ESC key before leaving
this field.
- From the File menu
choose Save table
name.