Got a complex SELECT query, from which I would like to insert all rows into a table variable, but T-SQL doesn\'t allow it.
Along the same lines, you c
The purpose of SELECT INTO is (per the docs, my emphasis)
To create a new table from values in another table
But you already have a target table! So what you want is
The
INSERTstatement adds one or more new rows to a tableYou can specify the data values in the following ways:
...
By using a
SELECTsubquery to specify the data values for one or more rows, such as:INSERT INTO MyTable (PriKey, Description) SELECT ForeignKey, Description FROM SomeView
And in this syntax, it's allowed for MyTable to be a table variable.