执行SQL Server存储过程 - 附近的语法不正确

时间:2022-06-18 22:48:23

I am getting the following error.

我收到以下错误。

Msg 102, Level 15, State 1, Line 5
Incorrect syntax near '@ExcludedDivisionBracketPartIds'.

消息102,级别15,状态1,行5'@ExcludedDivisionBracketPartIds'附近的语法不正确。

I have no idea why this is happening. If I execute the stored procedure directly it works fine.

我不知道为什么会这样。如果我直接执行存储过程它工作正常。

exec sp_executesql N'EXEC [TEST].[DeleteDivisionBracketPartsTEST]  
@DivisionBracketId 
@ExcludedDivisionBracketPartIds 
@MemberId',
N'@DivisionBracketId int,
@ExcludedDivisionBracketPartIds nvarchar(max),
@MemberId int',
@DivisionBracketId=145,
@ExcludedDivisionBracketPartIds=N'473',
@MemberId=53

ALTER PROCEDURE [TEST].[DeleteDivisionBracketPartsTEST]
    @DivisionBracketId INT,
    @ExcludedDivisionBracketPartIds NVARCHAR(MAX),
    @MemberId INT
AS
BEGIN
    SET NOCOUNT ON;

1 个解决方案

#1


3  

You missed the commas After @DivisionBracketId and @ExcludedDivisionBracketPartIds.

在@DivisionBracketId和@ExcludedDivisionBracketPartIds之后你错过了逗号。

it should be like:

它应该是这样的:

exec sp_executesql N'EXEC [TEST].[DeleteDivisionBracketPartsTEST]  
@DivisionBracketId, 
@ExcludedDivisionBracketPartIds, 
@MemberId',
N'@DivisionBracketId int,
@ExcludedDivisionBracketPartIds nvarchar(max),
@MemberId int',
@DivisionBracketId=145,
@ExcludedDivisionBracketPartIds=N'473',
@MemberId=53

ALTER PROCEDURE [TEST].[DeleteDivisionBracketPartsTEST]
    @DivisionBracketId INT,
    @ExcludedDivisionBracketPartIds NVARCHAR(MAX),
    @MemberId INT
AS
BEGIN
    SET NOCOUNT ON;

#1


3  

You missed the commas After @DivisionBracketId and @ExcludedDivisionBracketPartIds.

在@DivisionBracketId和@ExcludedDivisionBracketPartIds之后你错过了逗号。

it should be like:

它应该是这样的:

exec sp_executesql N'EXEC [TEST].[DeleteDivisionBracketPartsTEST]  
@DivisionBracketId, 
@ExcludedDivisionBracketPartIds, 
@MemberId',
N'@DivisionBracketId int,
@ExcludedDivisionBracketPartIds nvarchar(max),
@MemberId int',
@DivisionBracketId=145,
@ExcludedDivisionBracketPartIds=N'473',
@MemberId=53

ALTER PROCEDURE [TEST].[DeleteDivisionBracketPartsTEST]
    @DivisionBracketId INT,
    @ExcludedDivisionBracketPartIds NVARCHAR(MAX),
    @MemberId INT
AS
BEGIN
    SET NOCOUNT ON;