0 votes
in Sql by
How to Fix 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 SQL Server Keeps giving this error:

Invalid column name 'INCL_GSTAMOUNT'

1 Answer

0 votes
by
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.

This error may ALSO occur in encapsulated SQL statements e.g.

DECLARE @tableName nvarchar(20) SET @tableName = 'GROC'

DECLARE @updtStmt nvarchar(4000)

SET @updtStmt = 'Update tbProductMaster_' +@tableName +' SET department_str = ' + @tableName exec sp_executesql @updtStmt

Only to discover that there are missing quotations to encapsulate the parameter "@tableName" further like the following:

SET @updtStmt = 'Update tbProductMaster_' +@tableName +' SET department_str = ''' + @tableName + ''' '

Related questions

0 votes
asked Mar 15, 2022 in Azure SQL by sharadyadav1986
0 votes
asked Jul 10, 2020 in Sql by SakshiSharma
...