0

下面是我的 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.

4

1 回答 1

0

我没有看到代码可以直接导致它。

可能你INSERT的表上有一个错误的触发器,它假设INSERTED只包含单行并且多行插入失败。

于 2013-10-22T08:53:51.460 回答