Whats wrong with sp_rename with column?

Viewed 17414

I am using following SQL command with sp_rename to rename a column.

USE MYSYS;
GO
EXEC sp_rename 'MYSYS.SYSDetails.AssetName', 'AssetTypeName', 'COLUMN';
GO

But it is causing an error:

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

Please suggest how to rename a column using sp_rename.

[ this command I am using found at Microsoft Technet ]

4 Answers

I got this error because column name was not correct. Sometimes wrong table name or wrong column name may cause this issue.

For me it worked

USE **DatabaseName**
GO
EXEC sp_rename 'Schema.TableName.ColumnName', 'NewColumnName', 'COLUMN';
GO

Here is the example which worked for me

EXEC sp_rename 'dbo.Facility.facilityName', 'FacilityName', 'COLUMN'
Related