Simple way of renaming a column in SQL Server is
Other way is using the Stored Procedure "sp_rename"
Syntax:
- Go to the Table Designer
- Modify the column name
- Save the changes
Other way is using the Stored Procedure "sp_rename"
Syntax:
Exec sp_rename [ @objname = ] 'object_name' , [ @newname = ] 'new_name' [ , [ @objtype = ] 'object_type' ]
Example:
EXEC sp_rename N'dbo.tbl_Details.MailID', N'e-MailID', 'COLUMN'
When the above command is executed, the column named "MailID" in the table "tbl_Details" will be renamed to "e-MailID"
By using the stored procedure sp_rename, the following object types can be renamed
- Column
- Database
- Index
- Object
- UserDataType
No comments:
Post a Comment