How to fix “Must declare the scalar variable” error when referencing table variable?

后端 未结 1 917
栀梦
栀梦 2020-12-06 04:41

I can\'t figure out why (or maybe you just can\'t do this) I get the out of scope error

Must declare the scalar variable \"@CompanyGroupSites_Master.

相关标签:
1条回答
  • 2020-12-06 05:12

    This is a long standing parser issue. You need to get rid of the table prefix or wrap it in square brackets.

    i.e.

    delete from @CompanyGroupSites_Master 
    where CompanyGroupID = @CompanyGroupID
    

    or

    delete from @CompanyGroupSites_Master 
    where [@CompanyGroupSites_Master].CompanyGroupID = @CompanyGroupID
    

    Not

    delete from @CompanyGroupSites_Master 
    where @CompanyGroupSites_Master.CompanyGroupID = @CompanyGroupID
    
    0 讨论(0)
提交回复
热议问题