我的代码中有WITH AS
子句
DECLARE @MyTable TABLE(Field_1 INT, Field_2 INT)
INSERT @MyTable VALUES
(1,2),
(2,2)
WITH x AS ( SELECT Field_1, Field_2 FROM @MyTable)
SELECT * FROM x
如何将上述代码的结果插入到同一张表中?我想插入如下:
DECLARE @MyTable TABLE(Field_1 INT, Field_2 INT)
INSERT @MyTable VALUES
(1,2),
(2,2)
WITH x AS ( SELECT Field_1, Field_2 FROM @MyTable)
INSERT INTO @MyTAble (SELECT * FROM x)
SELECT * FROM @MyTable
但它不起作用。Management Studio mark @MyTAbl
e likeInvalid object name @MyTable
我该怎么做?我正在使用 SQL Server 2008 R2。