为什么我的select @@ rowcount返回Subquery的SqlException返回的值超过1?

时间:2015-06-26 03:42:36

标签: c# sql-server

我有一个应用程序调用执行以下操作的存储过程:

update tableA set duedate=@duedate where id=@id;
select @@RowCount;

在客户端服务器上部署我的应用程序时,出现错误:

"子查询返回的值超过1。当子查询遵循=,!=,<,< =,>,> =或在表达式上使用子查询时,不允许这样做"

我在C#中使用命令:

executeScalar(...)

有什么东西我似乎缺少配置吗?我已经在我的服务器上测试了它,它似乎工作正常。

编辑:整个存储过程

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE UpdateDueDates
-- Add the parameters for the stored procedure here
@batchNumber varchar(15),
@dueDate date
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

-- Insert statements for procedure here
update dbo.ItemTable
set DUEDATE = @dueDate
where
BATCHNUMBER = @batchNumber;

-- Returns the number of Updates
select @@ROWCOUNT;
END
GO

1 个答案:

答案 0 :(得分:2)

我怀疑TableA上有更新触发器。我已经看到许多触发器,它们假设行一次插入或更新一行。执行更新多行的更新语句时,触发器将失败。