tsql - T-Sql Algorithm Question -
i have t-sql statement follows;
insert table1 select * table2
i want know running sequence. insert waits select statement finish before starting or starts asap select statement starts returning values , expects new records select statement continue.
this plain stored procedure , no transactions used.
to echo @codebymoonlight's answer, , address comment there: physical considerations (including specifics of locking) subordinate logical instructions specified query.
in processing of insert ... select
statement, logically speaking select
carried out produce resultset, , rows of resultset insert
ed. fact in case source table , target table same table irrelevant. i'm sure specifying nolock
or tablock
in case apply select
, if that's position them.
consider example statement, makes no sense if read in 'imperative' way:
update sometable set column1 = column2, column2 = column1
with imperative, rather set-based, understanding, statement might if result in column1
, column2
having same value rows. doesn't - in fact swaps values in column1
, column2
. understanding logical instructions of query dictate happens can seen.
Comments
Post a Comment