SQL Server Invalid Column name after adding new column

kingrichard2005 picture kingrichard2005 · Apr 26, 2012 · Viewed 73.3k times · Source

I just added an identity column to an existing table with data through the SSMS Designer, the table updates fine and I can run a select query against it successfully, but after the query finishes I noticed that the new column is underlined in red with an error indicating it's an invalid column name.

Why does this occur? I would expect the query to fail if the column was invalid.

Does the SSMS keep some type of internal reference to the old table that must be flushed?

I tried closing the DB connection and reopening it, but still the same error. Not sure what I'm missing here.

SELECT TOP 100 
[PRIMARY_NDX_Col1],
[NEW_Col], --QUERY EXECUTES SUCCESSFULLY, BUT THIS IS UNDERLINED RED AS AN INVALID COLUMN
[Col3]
FROM [dbo].[MyTable]

Answer

David Brabant picture David Brabant · Apr 26, 2012

you can either

  • Press Ctrl+Shift+R

OR

  • Go to Edit >> IntelliSense >> Refresh Local Cache