Environment: SQL Server 2008 R2
Problem: When calling stored procedure sp_rename "parameter @objname ambiguous or declared @objtype (column) is incorrect".
Solve:
Look at the following commands, if you first execute the first two sentences, and then execute the third sentence what will happen?
Use test;--the database
sp_rename ' D_s_t.avg_grade ', ' avg_g ', ' column ';--d_s_t is the table name, Avg_grade is the original column name, and Avg_g is the new column name
exec Sp_rename ' D_s_t.avg_grade ', ' avg_g ', ' column ';
Yes, you're right. will report the error as described above.
Since you executed the second sentence, your original column has changed the name, and you can't find it again with the original column.
If the third sentence is to be further implemented, it can be changed to read:
exec sp_rename ' d_s_t.
Avg_g ', ' avg_g_new ', ' column ';
PS: Oh, this error is due to their carelessness, so the programmer must have a meticulous heart.