以下是我的SQL查询
BEGIN TRAN
DECLARE @PRE_CD INT = (SELECT ISNULL(MAX(PRE_CD), 0) FROM TBL_MAIN)
INSERT INTO TBL_MAIN
(PRE_CD,
PRE_DESC,
PRE_REF_CD)
SELECT ROW_NUMBER() OVER (ORDER BY PRESENTATION) + @PRE_CD,
PRESENTATION,
3
FROM (SELECT DISTINCT PRESENTATION
FROM Temp_Data
WHERE PRESENTATION NOT IN (SELECT PRE_DESC
FROM TBL_MAIN)) T
COMMIT;
执行此查询时出现错误
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
答案 0 :(得分:0)
我没有看到代码可以直接导致它。
可能你在表上有一个错误的INSERT
触发器,它假定INSERTED
只包含一行而且多行插入失败。