I have WITH AS clause in my code
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
How can I insert result of above code to the same table?
I’m tring to insert like:
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
But it does not work. Management Studio mark @MyTAble like Invalid object name @MyTable
How can I do it? I’m using SQL Server 2008 R2.
Maybe you meant this (semi-colons and other little syntax things are important!),
…but I don’t think this will work in MySQL.