Must declare scalar variable in sql server dynamic sql

后端 未结 1 1383
慢半拍i
慢半拍i 2021-01-25 22:25

I am having problems running sql server stored procedure. I using a dynamic sql. I get the error \"Must declare the scalar variable \"@EmployeeId\".

SQL QUERY

相关标签:
1条回答
  • 2021-01-25 23:11

    The second sp_executesql parameter should be a single string with all parameter definitions. Try:

    EXECUTE sp_executesql @queryString,
        N'@AdminId int, @EmployeeId int',
         @AdminId = @AdminId,
         @EmployeeId = @EmployeeId;
    
    0 讨论(0)
提交回复
热议问题