Developer ToolsFree generatorPDF, Excel, Word export

Excel to SQL INSERT Statement Generator

Data migration and master data cleanup often start in Excel. This generator gives you a correct INSERT pattern and the Excel formula that turns each row into a SQL values line, with quote escaping and a transaction wrapper.

Fill in

Generated code
Download:

Insert statement

BEGIN TRANSACTION;

INSERT INTO stg_item_master (item_code, description, uom, std_cost)
VALUES
  ('PN-1001', 'Bracket, mounting', 'EA', 12.50),
  ('PN-1002', 'Washer 6 mm', 'EA', 0.08),
  ('PN-1003', 'Cable 2 core', 'M', 1.35);

-- Check before committing
SELECT COUNT(*) AS rows_loaded FROM stg_item_master;

-- COMMIT TRANSACTION;
-- ROLLBACK TRANSACTION;

Excel formula that builds each values line

-- Put this in column E, row 2, then fill down. Columns A to D hold item, description, uom, cost.
="  ('"&SUBSTITUTE(A2,"'","''")&"', '"&SUBSTITUTE(B2,"'","''")&"', '"&C2&"', "&D2&"),"

-- Copy column E into the VALUES list. Remove the final comma and end with a semicolon.

Load tracking comment

-- Batch: LOAD-2026-10-20
-- Source: Excel file, sheet 1, rows 2 to 4
-- Loaded by: your name, date, ticket number

Always load into a staging table first, never straight into live ERP tables, and let the ERP's own import or API validate and post the data. SQL Server limits a VALUES list to 1,000 rows per INSERT; split larger loads or use BULK INSERT, bcp or an import wizard. Quote text, leave numbers and NULL unquoted, and write dates in an unambiguous format such as 2026-10-20.

Validated data loads into your ERP

Want a staged, validated import flow for recurring loads? Optional walkthrough.

Optional. The tool and every export work without this. No spam.

How to use it

Enter the target staging table, the column list in the same order as your spreadsheet columns, and a few sample rows to see the output. Then copy the Excel formula block into a helper column, adjust the column letters to your sheet, and fill down. Paste the generated lines into the VALUES list. Run the script inside the transaction, check the row count with the SELECT, and only then uncomment COMMIT. If the count is wrong, ROLLBACK leaves the table untouched.

Quoting and data types

Text must be wrapped in single quotes, and any single quote inside the text doubled, which the SUBSTITUTE function in the formula does. Numbers go in without quotes, and blank cells should become NULL, not empty strings, if the column allows it. Dates are safest as ISO text such as 2026-10-20. Leading zeros in part numbers survive only if the value is treated as text, so format the Excel column as Text first. Check decimal separators; some regional settings export 12,50 instead of 12.50.

  • Double single quotes inside text
  • Use NULL for empty values where allowed
  • Format ID columns as Text before copying
  • Use ISO dates

Staging, validation and reconciliation

Load into a staging table, then validate before anything reaches the ERP: duplicate keys, missing required fields, values not in the master lists, text longer than the target column and negative quantities. Record row counts and a control total, for example the sum of standard cost, in Excel and compare to the table after load. Keep the original spreadsheet and the generated script with your change record so the load can be explained and repeated.

Common mistakes

Loading straight into live tables bypasses ERP validation and can corrupt related records. An unescaped apostrophe, as in a description like 6 mm O'Ring, breaks the script or worse, changes its meaning. Excel silently converting long numbers to scientific notation damages part and serial numbers. Forgetting that a trailing comma ends the last values line causes a syntax error. Executing a script written by someone else without reading it is the most dangerous habit of all.

Frequently Asked Questions

How do I convert an Excel sheet to SQL INSERT statements?

Use a helper column with a concatenation formula that wraps text in quotes and escapes apostrophes, fill it down, then paste the results into an INSERT ... VALUES list. For large files, use an import wizard, bcp or BULK INSERT instead.

What is the row limit for INSERT VALUES in SQL Server?

A single INSERT with a VALUES list can contain up to 1,000 row value expressions in SQL Server. Split bigger sets into several statements, or import the file with a bulk tool. Other databases have different limits.

How do I insert a NULL from Excel?

Use a formula such as IF(A2="","NULL","'"&A2&"'") so empty cells output the unquoted word NULL. An empty quoted string is a real value and can break foreign keys and required checks.

Should I insert directly into ERP tables?

No. Use a staging table and the ERP's own import program, API or web service so business rules, numbering and audit trails apply. Direct inserts can leave the ERP inconsistent and may void vendor support.

If you run recurring spreadsheet loads into your ERP, we can build a validated, approval-based import flow that shows the proposed changes before anything is written.