I want to create a table using the results of a query by utilizing SELECT INTO.
The syntax
SELECT *
INTO Persons_Backup
FROM Persons
is very close to what I want to achieve, with the difference being that I want the FROM to use a query as source.
Something like
SELECT *
INTO Persons_Backup
FROM (Select 1, 'a',' 2001-01-01 12:00')
does not work, but gives an idea of what I want to do. How can I accomplish this?
I will be using SQL2008
Make your select statement like normal ignoring the
INTOpart.It should work fine. For your example:
Or more complicated
This will also work