January 4, 2018 at 11:42 am
Case1
$sql ="
INSERT INTO dbo.DbSecurity (Servername,DatabaseName,ContactUser) VALUES ('Server1','Db1,'User1');
INSERT INTO dbo.DbSecurity (Servername,DatabaseName,ContactUser) VALUES ('Server1','Db1,'User1');
INSERT INTO dbo.DbSecurity (Servername,DatabaseName,ContactUser) VALUES ('Server1','Db1,'User1');
INSERT INTO dbo.DbSecurity (Servername,DatabaseName,ContactUser) VALUES ('Server1','Db1,'User1');
INSERT INTO dbo.DbSecurity (Servername,DatabaseName,ContactUser) VALUES ('Server1','Db1,'User1');
INSERT INTO dbo.DbSecurity (Servername,DatabaseName,ContactUser) VALUES ('Server1','Db1,'User1');
INSERT INTO dbo.DbSecurity (Servername,DatabaseName,ContactUser) VALUES ('Server1','Db1,'User1');
INSERT INTO dbo.DbSecurity (Servername,DatabaseName,ContactUser) VALUES ('Server1','Db1,'User1');
"
$Command.CommandText = $sql
Command.ExcuteNonQuery() SQL profiler show CPU = 0 Duration 8 as result of bacth Case2 $i =0
if($i -le 8) {
$sql ="INSERT INTO dbo.DbSecurity (Servername,DatabaseName,ContactUser) VALUES ('Server1','Db1,'User1');"
$Command.CommandText = $sql
$Command.ExcuteNonQuery()
$i++
}
SQL profiler show CPU = 0 Duration 1 -- for each executionQuestion
Do we save on script execution time when submit batch of 500000 rows using call in (in case 1) looop 500000 times inserting row by row (Case2)?
January 4, 2018 at 11:53 am
I suggest looking into SqlBulkCopy with a DataTable.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply