Create Table Destination (
ID_Test Int Identity (1,1) Primary Key,
Cod_Test VarChar (20),
Test VarChar (100))
Go
Create Table RowsToInsert (
Cod_Test VarChar (20),
Test VarChar (100))
Go
set statistics time on;
INSERT
Destination
SELECT
Cod_Test,
Test
FROM
RowsToInsert
OPTION (RECOMPILE)
--4750 ms
This below method is the fastest
way of inserting the records in to sql server and reduces sort operation in the sql server engine.
INSERT
Destination
SELECT
Cod_Test,
Test
FROM
(SELECT 1 A, * FROM RowsToInsert) Q
ORDER BY A
OPTION (RECOMPILE)
--4689ms
No comments:
Post a Comment