我有一个 C# 应用程序,它传入以下数据:
数据集ID = 10;用户 ID = 1; varnames = "'ACT97','ACTCHNG','ACTQTR2','ACTSCOR2'";
存储过程是:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[s_LockCheck]
-- Add the parameters for the stored procedure here
@varNames VARCHAR(max),
@datasetID INT,
@userID INT
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON
SELECT COUNT(*) as locked FROM VarLocks WHERE var_name IN (@varNames) AND dataset_id = @datasetID AND user_id != @userID AND is_locked = 1
END
但是当我这样称呼它时,当它应该高于它时,它返回的计数为 0:
exec s_LockCheck "'ACT97','ACTCHNG','ACTQTR2','ACTSCOR2'", 88, 14
上面的每个 ACTXXX 都是列 var_name 中的一个 varname。
为什么它没有正确执行 IN 子句?