Can you please advise on how to write this code properly:
declare @str nvarchar(50)
Set @str = '[table1].[column_name1]'
sp_RENAME @str, 'column2', 'COLUMN'
It currently gives an error
Incorrect syntax near ‘sp_RENAME’
This should be equivalent with:
sp_RENAME '[table1].[column1]', '[column2]', COLUMN
that is used to rename a column from a table.
I need to use the first method because this happens as a general step in a procedure.
Thanks a lot!
I just tried your code and had no problems at all, could it be that you forgot to use “execute” to call the stored procedure?