2

I'm trying to rename a few columns within a table that's already created:

  USE AdventureWorks
  GO

  EXEC sp_RENAME 'registration.StudentID', 'Temp', 'COLUMN';
  GO

But I'm getting this error message:

Either the parameter @objname is ambiguous or the claimed @objtype (COLUMN) is wrong.

If I omit 'COLUMN', this error appears:

No item by the name of 'registration.StudentID' could be found in the current database 'AdventureWorks', given that @itemtype was input as '(null)'.

I'm pretty sure that the StudentID column exists and has data in there. Can anyone help me out? Thanks!!!

4

2 回答 2

3

根据评论,这就是您所需要的。

USE registration;

EXEC sp_rename 'dbo.enrollment.StudentID', 'Temp', 'COLUMN';
于 2012-11-14T08:03:47.367 回答
0

the correct call is

sp_RENAME 'TableName.[OldColumnName]' , '[NewColumnName]', 'COLUMN'

so I think ur code should be

USE AdventureWorks
  GO
  EXEC sp_RENAME '[registration].StudentID', 'Temp', 'COLUMN';

  Go
于 2012-11-14T07:31:54.513 回答