05.30.08

Query to Change Column Name in sql server

Posted in Important SQL Query, Interview Questions, SQL Server tagged , at 6:58 am by dayananthan

I have created an Table Test with wrong column name as EepId instead of EmpID, and now i want to change it to EmpID, the following is the query to get

create table Test

(

EepID int

)

 insert into Test values(2)

 Now I want EepID column to Change to EmpID. The following is the solution

 EXEC sp_rename

    @objname = ‘Test.EepID’,

    @newname = ‘EmpID’,

    @objtype = ‘COLUMN’