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

时间:2012-08-27 21:44:08

标签: sql-server stored-procedures

我收到以下错误。

  

Msg 102,Level 15,State 1,Line 5
  '@ExcludedDivisionBracketPartIds'附近的语法不正确。

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

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 个答案:

答案 0 :(得分:3)

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

应该是这样的:

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;