MSSQL Comment insérer plus de 1000 lignes
BEGIN TRANSACTION; -- Whenever possible use transactions when dealing with large amounts of data
INSERT INTO [database].[dbo].[table_name] ([field1], [field2], [field3])
SELECT 'value for row 1 field 1', 'value for row 1 field 2', 'value for row 1 field 3' UNION ALL
SELECT 'value for row 2 field 1', 'value for row 2 field 2', 'value for row 2 field 3' UNION ALL
-- ...N-thousand other rows...
SELECT 'value for row n-1 field 1', 'value for row n-1 field 2', 'value for row n-1 field 3' UNION ALL
SELECT 'value for row n field 1', 'value for row n field 2', 'value for row n field 3'; -- No 'UNION ALL' statement on the last line
COMMIT TRANSACTION;
Dami