标签:ons mon and tin com creat nim dia .com
What is the difference between using
SELECT ... INTO MyTable FROM...
and
INSERT INTO MyTable (...)
SELECT ... FROM ....
?
From BOL [ INSERT, SELECT...INTO ], I know that using SELECT...INTO will create the insertion table on the default file group if it doesn‘t already exist, and that the logging for this statement depends on the recovery model of the database.
Edit: I already stated that I know that that SELECT INTO... creates a table where it doesn‘t exist. What I want to know is that SQL includes this statement for a reason, what is it? Is it doing something different behind the scenes for inserting rows, or is it just syntactic sugar on top of a CREATE TABLEand INSERT INTO.
INSERT
when the table exists. Use SELECT INTO
when it does not.INSERT
with no table hints is normally logged. SELECT INTO
is minimally logged assuming proper trace flags are set.SELECT INTO
is most commonly used with intermediate data sets, like #temp
tables, or to copy out an entire table like for a backup. INSERT INTO
is used when you insert into an existing table with a known structure.标签:ons mon and tin com creat nim dia .com
原文地址:http://www.cnblogs.com/bi-info/p/6222674.html