SQL Server BULK INSERT Options
SQL Server BULK INSERT Options is a SQL statement in the SQL Server Specific category. SQL Server BULK INSERT with options for batch size, error handling, and performance tuning. The syntax is BULK INSERT t FROM 'file' WITH (FIELDTERMINATOR = ',', ROWTERMINATOR = '\ ', FIRSTROW = 2);. It returns bulk insert completed. A typical example: BULK INSERT employees FROM 'C:\data\employees.csv' WITH ( FIELDTERMINATOR = ',', ROWTERMINATOR = '\ ', FIRSTROW = 2, -- Skip header BATCHSIZE = 1000, -- Commit every 1000 rows MAXERRORS = 5, -- Stop after 5 errors TABLOCK, -- Table-level lock (faster) ROWS_PER_BATCH = 50000, -- Optimize for 50K rows CODEPAGE = '65001', -- UTF-8 ERRORFILE = 'C:\data\errors.log' ); -- For large files, use: -- TABLOCK: minimizes logging -- BATCHSIZE: controls… A close relative is OUTPUT Clause, which sQL Server: returns values from DML statements (like PostgreSQL RETURNING). A close relative is STUFF(), which sQL Server: deletes a specified length of characters from a string and inserts another string at the start position.