Search code examples
databasessmssql-server-2014sp-rename

SP_RENAME causing 'invalid column name' issue


I say 'issue' because it's not breaking anything, it's merely a small thing I've noticed in SSMS.

I run the following:

SP_RENAME 'MyTable.OldName', 'NewName' , 'COLUMN'

And then type the following in SSMS:

SELECT [NewName] FROM MyTable;

The [NewName] part now has a red squiggly line under it with a 'Invalid column name' warning.

Why? Is the old name cached in SSMS somehow somewhere? Is my column rename incomplete somehow? I don't really care if it's a bug of SSMS, but I'd like to know there isn't a 'step 2' I'm meant to do once renaming a column.

Note: If I type SELECT [OldName] FROM MyTable; I don't get the warning, but it (obviously) doesn't run.


Solution

  • "Is the old name cached in SSMS somehow somewhere" - Yes.

    Go to Edit => IntelliSense => Refresh or Ctrl+Shift+R to make it update itself.

    You don't need to do anything else, its a false warning.