Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server: Invalid Column Name

I am working on modifying the existing SQL Server stored procedure. I added two new columns to the table and modified the stored procedure as well to select these two columns as well. Although the columns are available in the table, I keep getting this error:

Invalid column name 'INCL_GSTAMOUNT'

enter image description here

Can anyone please tell me what's wrong here?

like image 737
Kamran Ahmed Avatar asked Sep 22 '13 07:09

Kamran Ahmed


People also ask

Why does SQL Server show invalid column name?

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.

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.

Why does SQL say invalid object name?

This typically means 1 of 2 things... you've referenced an object (table, trigger, stored procedure,etc) that doesn't actually exist (i.e., you executed a query to update a table, and that table doesn't exist). Or, the table exists, but you didn't reference it correctly...

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.


2 Answers

Whenever this happens to me, I press Ctrl+Shift+R which refreshes intellisense, close the query window (save if necessary), then start a new session which usually works quite well.

like image 144
Ric Avatar answered Sep 24 '22 06:09

Ric


Could also happen if putting string in double quotes instead of single.

like image 25
Harry Avatar answered Sep 26 '22 06:09

Harry