All Type Coding

Search Here

How to rename a table column name in sql server / How to change column name in sql server

Here, we have a table Employee like below.














Syntax:
sp_rename 'TableName.Column_name','write the changed name whatever you want to put ','COLUMN'

Now I want to change or rename a Employee table column EmpName. I want to rename with Name only.then execute below query
sp_rename 'Employee.EmpName','Name','COLUMN'

After executing the above query output will be like below.












Now you can see the previously column name was EmpName but Now after changing it has changed Name .
So, following above process we can change the table column name easily.

No comments :

Post a Comment