Note:
In the example in #24, you can also use (global) temporary tables (e. g. ##GUID-string) as the target and then use a direct sql statement (or call a sql procedure) via pass-though query or ADODB/OLEDB connection to insert the data into the original table.
The problem is that each data record is transferred individually via ODBC. If a trigger then runs in the target table, for example, it runs for each individual data record.
With
Profiler log:
With
In the example in #24, you can also use (global) temporary tables (e. g. ##GUID-string) as the target and then use a direct sql statement (or call a sql procedure) via pass-though query or ADODB/OLEDB connection to insert the data into the original table.
The problem is that each data record is transferred individually via ODBC. If a trigger then runs in the target table, for example, it runs for each individual data record.
With
Insert into Tab (...) select ... an Insert SQL statement is executed for each data record.Profiler log:
Code:
exec sp_executesql N'INSERT INTO "dbo"."Tab123" ("ID","P","Z") VALUES (@P1,@P2,@P3)',N'@P1 int,@P2 nvarchar(255),@P3 int',1,NULL,NULL
exec sp_executesql N'INSERT INTO "dbo"."Tab123" ("ID","P","Z") VALUES (@P1,@P2,@P3)',N'@P1 int,@P2 nvarchar(255),@P3 int',2,N'JP16',NULL
...
With
select ... into ... the insert statement is converted into a temp procedure and this procedure is called for each data record.
Code:
declare @p1 int set @p1=1 exec sp_prepexec @p1 output,N'@P1 int,@P2 nvarchar(4000),@P3 int',N'INSERT INTO "Tab123" VALUES (@P1,@P2,@P3)',1,NULL,NULL select @p1
exec sp_execute 1,2,N'JP16',NULL
...
Last edited: