Thursday, 20 November 2014

Rename table



    Using SP_RENAME we can rename SQL Server data base objects (Tables, Views, Functions and Procedures). Using SP_RENAME we can rename columns also.

Rename table:
Syntax:
SP_RENAME '<Database name>.<Schema name>.<Table Name>','<New Name>'

Example:
Table Creation:


CREATE TABLE SAMPLE13
(
ID INT ,
NAME VARCHAR(10),
TYPE_DESC VARCHAR(50)
)

Renaming Table:



SP_RENAME 'KIRAN.DBO.SAMPLE13','TEST_TBL'



No comments:

Post a Comment