此 SQL SERVER 2005 语句首先删除 18 条记录FIELD1 ASC
,然后将相同的 18 条记录插入到克隆表中:
WITH q AS
(
SELECT TOP 18 *
FROM pippo
ORDER BY FIELD1 ASC /* You may want to add ORDER BY here */
)
DELETE
FROM q
OUTPUT DELETED.* INTO TableNew
请帮我将前面的语句转换为 first INSERT
,并且THEN
-IF INSERT
已确定 - 删除相同的 18 条记录;我刚刚尝试过,但以下代码给出了错误,
Msg 102, Level 15, State 1, Line 7 Incorrect syntax near 'INSERTED'.
WITH q AS
(
SELECT TOP 18 *
FROM pippo
ORDER BY ID_OL ASC /* You may want to add ORDER BY here */
)
insert into tablenew select * from q OUTPUT INSERTED.* INTO TABLENEW
预先感谢您的帮助。