SQL 带有 OUTPUT 的服务器 DELETE 无法使用 table 别名
SQL Server DELETE with OUTPUT not working with table alias
我收到 OUTPUT 语句的“'OUTPUT' 附近语法不正确”错误。玩弄它,似乎是 OUTPUT 语句不喜欢 table 别名 D。但我需要 DELETE 才能使用 exists 子句。知道如何解决这个问题吗?
DELETE D FROM #VARNAMES D
OUTPUT DELETED.VARNAME INTO #Table2
WHERE EXISTS (SELECT 1 FROM CIT
WHERE RID LIKE '123%'
AND RULES LIKE '%Storage.' + D.VARNAME + '"%')
在 SQL 服务器中 OUTPUT
在 FROM
之前:
DELETE D
OUTPUT DELETED.VARNAME INTO #Table2
FROM #VARNAMES D
WHERE EXISTS (SELECT 1 FROM CIT
WHERE RID LIKE '123%'
AND RULES LIKE '%Storage.' + D.VARNAME + '"%')
;
根据 documentation,output
在 from
之前
DELETE D
OUTPUT DELETED.VARNAME INTO #Table2
FROM #VARNAMES D
WHERE EXISTS (SELECT 1 FROM CIT
WHERE RID LIKE '123%'
AND RULES LIKE '%Storage.' + D.VARNAME + '"%')
我收到 OUTPUT 语句的“'OUTPUT' 附近语法不正确”错误。玩弄它,似乎是 OUTPUT 语句不喜欢 table 别名 D。但我需要 DELETE 才能使用 exists 子句。知道如何解决这个问题吗?
DELETE D FROM #VARNAMES D
OUTPUT DELETED.VARNAME INTO #Table2
WHERE EXISTS (SELECT 1 FROM CIT
WHERE RID LIKE '123%'
AND RULES LIKE '%Storage.' + D.VARNAME + '"%')
在 SQL 服务器中 OUTPUT
在 FROM
之前:
DELETE D
OUTPUT DELETED.VARNAME INTO #Table2
FROM #VARNAMES D
WHERE EXISTS (SELECT 1 FROM CIT
WHERE RID LIKE '123%'
AND RULES LIKE '%Storage.' + D.VARNAME + '"%')
;
根据 documentation,output
在 from
DELETE D
OUTPUT DELETED.VARNAME INTO #Table2
FROM #VARNAMES D
WHERE EXISTS (SELECT 1 FROM CIT
WHERE RID LIKE '123%'
AND RULES LIKE '%Storage.' + D.VARNAME + '"%')