SQL
Batch Insert Multiple Records into a Table
Perform a high-performance batch insert operation in SQL to add multiple new records into a table efficiently, reducing database round trips and overhead.
INSERT INTO Products (ProductName, Price, CategoryID)
VALUES
('Laptop Pro', 1200.00, 101),
('Mechanical Keyboard', 150.00, 102),
('Gaming Mouse', 75.00, 102),
('4K Monitor', 450.00, 103);
How it works: This code demonstrates how to insert multiple rows into a SQL table using a single INSERT statement. This 'batch insert' method is significantly more efficient than executing individual INSERT statements for each row, as it minimizes network round trips and database overhead, leading to faster data ingestion and better performance for bulk operations.