Monday, May 24, 2010

How to rename table

How to rename table in SQL Server using T-SQL

 

How to rename big\huge tables?

 

The best way of renaming table is using system SP

SP_RENAME

 

Make sure that you are in same DB whose table you want to change.

 

Use DB

SP_RENAME ‘Table1’,’NewName’

 

SP_RENAME automatically renames the associated index whenever a PRIMARY KEY or UNIQUE constraint is renamed. If a renamed index is tied to a PRIMARY KEY constraint, the PRIMARY KEY constraint is also automatically renamed by sp_rename.

 

No comments:

Post a Comment