This may be a really basic SQL question, but I have seen a SQL INSERT statement without the clause INTO and I was wondering if that is some special case in SQL Server 2000 or 2008.
The INSERT statement look something like
INSERT <table_name>
(
column names
)
select *
from <another table>
where <condition>
Sorry, if this is super basic, but I just wanted to make sure. Thanks!
INSERT INTO is the standard. Even though INTO is optional in most implementations, it's required in a few, so it's a good idea to include it to ensure that your code is portable. You can find links to several versions of the SQL standard here.
If you are using Insert or Insert into both will insert the data in Table. However Insert into is basically used to fatch the data from another table using select command and insert into table where you want to insert the data.
INTO' creates the destination table, it exclusively owns that table and is quicker compared to the 'INSERT … SELECT'. Because the 'INSERT … SELECT' inserts data into an existing table, it is slower and requires more resources due to the higher number of logical reads and greater transaction log usage.
Your best bet is to copy-paste the data from the Word document into a text file and then use perl, python, java, etc. to generate your insert statements.
The INTO is optional. It is required in ANSI sql but the MS/Sybase developers decided to make it optional.
Check the BNF grammar http://savage.net.au/SQL/
92, 99, SQL:2003
<insert statement> ::= INSERT INTO <insertion target> <insert columns and source>
According to the ANSI spec, INTO should only be optional in a MERGE
clause.
For SQL Server (this link from 2000 to show how old it is - it exists from the first version of SQL Server), it is optional. It is also optional for MySQL.
INSERT [ INTO]
{ table_name WITH ( < table_hint_limited > [ ...n ] )
| view_name
| rowset_function_limited
}
{ [ ( column_list ) ]
{ VALUES
( { DEFAULT | NULL | expression } [ ,...n] )
| derived_table
| execute_statement
}
}
| DEFAULT VALUES
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With