子查询返回了 1 个以上的值.(在 while 循环中插入) [英] Subquery returned more than 1 value. (Insert within a while loop)
本文介绍了子查询返回了 1 个以上的值.(在 while 循环中插入)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
DECLARE @int int
DECLARE @saveamount int
DECLARE @savedate datetime
SET @int=1
SET @saveamount=400
SET @savedate= '20160101 13:00:00.00'
WHILE @int<=357
BEGIN
INSERT INTO watersave (reservoirid, amount, savedate)
VALUES (1,@saveamount,@savedate)
SET @int=@int+1
SET @saveamount=@saveamount+(SELECT ROUND((6 - 12 * RAND()), 0))
SET @savedate=@savedate+1
END
尝试插入以进行测试,但与子查询堆叠在一起,在第 9 行返回了 1 个以上的值错误.
Trying to insert for test purposes but stacked with the subquery returned more than 1 value error on line 9.
有什么想法吗?问候
推荐答案
由于您的 SQL 中似乎没有任何子查询,请检查 [watersave] 表上是否有任何触发器.
Since there does not appear to be any sub-queries in your SQL, check to see if there are any triggers on the [watersave] table.
参考:SQL Server子查询返回了 1 个以上的值.当子查询跟随 =, !=, <, <= , >, >=
这篇关于子查询返回了 1 个以上的值.(在 while 循环中插入)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文