Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Renaming a column: Incorrect syntax near 'SP_RENAME'.?

ALTER TABLE [TEMP]
SP_RENAME '[TEMP].[Day]', 'GT', 'COLUMN'

I am trying to rename Day to GT and am getting the error

Incorrect syntax near 'SP_RENAME'

SQL Server Management Studio says the error is on SP_RENAME

NOTE: I'm open to other options besides sp_rename

like image 563
Eric Francis Avatar asked May 31 '12 20:05

Eric Francis


Video Answer


1 Answers

SP_RENAME is not part of the ALTER TABLE statement. It is a system stored procedure and therefore it should be invoked using the EXEC/EXECUTE statement, like this:

exec SP_RENAME '[TEMP].[Day]', 'GT', 'COLUMN'

(without the alter table temp bit)

like image 175
juergen d Avatar answered Sep 19 '22 18:09

juergen d