We're going to explain here what is the difference between insert statement with into and without into.
Let's say that you need to created temporary table #StudentsList that will keep Ids from table Students; it will have only Id column.
- Advertisement -
We can insert values from table Students in the following ways:
INSERT INTO #StudentsList(Id) SELECT Id FROM Students
and
INSERT #StudentsList(Id) SELECT Id FROM Students
So, what is the difference between these two insert statements and is there really any difference in between them?
The answer is: there is no difference between the two statements.
Following the documentation:
[INTO] Is an optional keyword that can be used between INSERT and the target table.
- Advertisement -