Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server Invalid Column name after adding new column

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] 
like image 629
kingrichard2005 Avatar asked Apr 26 '12 17:04

kingrichard2005


People also ask

Why do I keep get invalid column name in SQL Server?

An invalid column name error in SQL means that the column name violates the conditions of the column name. If you reference an object that does not exist in the table or the name exists, but you did not reference it correctly, you will get this error.

How do I solve the ambiguous name column error in SQL?

One of the simplest ways to solve an “ambiguous name column” error — without changing column name — is to give the tables you want to join an alias. This sends a clear information to the SQL Machine the columns are different. Happy querying.

What are valid column names in SQL?

Column names must contain only A to Z, 0 to 9, and underscore (_) characters. Column names can contain multiple underscores. The column name must not be very generic. Avoid words such as term, multiplier, description, name, code, and so on.


1 Answers

you can either

  • Press Ctrl+Shift+R

OR

  • Go to Edit >> IntelliSense >> Refresh Local Cache
like image 196
David Brabant Avatar answered Oct 21 '22 06:10

David Brabant