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!!!

3
  • I see in your first version you had registration.dbo.Enrollment.StudentID, Can you clarify the database, schema, table and column names? Commented Nov 14, 2012 at 8:12
  • for sure, I made a typo earlier. database-registration, schema-dbo, table-enrollment, column-StudentID Commented Nov 14, 2012 at 8:37
  • So you should have use registration not use AdventureWorks and exec sp_rename 'dbo.enrollment.StudentID', 'Temp', 'COLUMN'; then Commented Nov 14, 2012 at 8:50

2 Answers 2

4

Based on the comments this is what you need.

USE registration;

EXEC sp_rename 'dbo.enrollment.StudentID', 'Temp', 'COLUMN';
Sign up to request clarification or add additional context in comments.

Comments

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

3 Comments

thanks for ur reply AMH!! I tried both '[registration].StudentID', 'Temp', 'COLUMN'; and 'registration.[StudentID]', '[Temp]', 'COLUMN'; but still getting the same error..
are u sure of the column name
ok try the accepted answer on stackoverflow.com/questions/5330070/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.