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’

  • How to Build Dynamic SQl for this?
  • How can I generate a hierarchy path in SQL that leads to a given node?
  • How to find out if a user exists in a db using sp_executesql?
  • Database Table design problem
  • SQL Database Project in Visual Studio
  • SQL Server: How to find the result with 2 criteria: one equals certain column; the other doesn't equal another column
  • enter image description here

    Can anyone please tell me what’s wrong here?

    8 Solutions collect form web for “SQL Server: Invalid Column Name”

    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.

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

    Intellisense is not auto refreshed and you should not fully rely on that

    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 + ”’ ‘


    I was getting the same error when creating a view.

    Imagine a select query that executes without issue:

    select id
    from products

    Attempting to create a view from the same query would produce an error:

    create view app.foobar as
    select id
    from products

    Msg 207, Level 16, State 1, Procedure foobar, Line 2
    Invalid column name ‘id’.

    For me it turned out to be a scoping issue; note the view is being created in a different schema. Specifying the schema of the products table solved the issue. Ie.. using dbo.products instead of just products.

    with refresh table or close and open sql server this work

    I had a similar problem.

    Issue was there was a trigger on the table that would write changes to an audit log table. Columns were missing in audit log table.

    I just tried.
    If you execute the statement to generate your local table, the tool will accept that this column name exists.
    Just mark the table generation statement in your editor window and click execute.

    MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.