SQL Server: Invalid Column Name

前端 未结 13 964
一个人的身影
一个人的身影 2020-12-22 23:49

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 column

13条回答
  •  春和景丽
    2020-12-23 00:13

    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 + ''' '

    Thanks

提交回复
热议问题