Posts

Showing posts with the label multivalues insert

SQL Server, other ideas for a fast insert ...multivalues!

Image
Hi Guys, Welcome back!   After yesterday's post , here is another one today, always light! Another trick for faster inserts! Enjoy the reading! Multivalues The T-SQL syntax allows the specification of more than one set of values ​​in the INSERT statement  For example: INSERT INTO Table (code,descr) VALUES ('0001','first item'), ('0002','second item'), ('0003','third item') We can specify a maximum of 1000 set of values. Let's see what we can do with it ... In some cases we could use this possibility to gain speed. The test Come on! follow me!   Let's create a simple heap table and insert some data, let's say 100,000 rows CREATE TABLE MOV (id int, Qty float) Now i use this loop to fill the table: DECLARE @i INTEGER ; SET @i = 0; WHILE @i < 100000 -- 100K BEGIN EXEC (' INSERT INTO MOV (id) VALUES (1) ') SET @i = @i + 1 END No...