HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Has SELECT an INSERT clause?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
hasselectinsertclause

Problem

I know the form

Select * into new_table from old_table


statement. Bur recently I found 2 posts here and here which use it like

SELECT * FROM NhlPlayer
INSERT INTO PlayerBackups


I find nothing in msdn, is that some new syntax or just a fault? I guess the later because

INSERT INTO PlayerBackups
SELECT * FROM NhlPlayer


would work fine.

Solution

Both posts are wrong syntax.

I've -1 in the first from SO and left a comment on the second.

Create a table

SELECT * INTO PlayerBackups FROM NhlPlayer


Inserts to an existing table

INSERT PlayerBackups SELECT * FROM PlayerBackups

Code Snippets

SELECT * INTO PlayerBackups FROM NhlPlayer
INSERT PlayerBackups SELECT * FROM PlayerBackups

Context

StackExchange Database Administrators Q#5465, answer score: 9

Revisions (0)

No revisions yet.