Rename a column in sql server 2005

aacrz
aacrz used Ask the Experts™
on
What is the command to rename a Column in a table, in sql server 2005.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
you can use sp_rename

EXEC sp_rename 'Yourtable.yourcolumn', 'yournewcolumnname', 'column'

http://sqlserverplanet.com/ddl/rename-column/

Author

Commented:
So this was my command.
exec sp_rename 'employee.extracolumn', 'newcolumn', 'column';
and my error is

Msg 15248, Level 11, State 1, Procedure sp_rename, Line 213
Either the parameter @objname is ambiguous or the claimed @objtype (column) is wrong.

Author

Commented:
I would like to Edit my Post to add that I am using SQL SERVER 2005 EXPRESS VERSION.
try adding some brackets

exec sp_rename '[employee].[extracolumn]', 'newcolumn', 'column';

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial