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