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
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.
Related Tools
SQL Date Range Filter Generator
Builds a correct half-open date range WHERE clause for four SQL dialects, so month-end and timestamp reports stop dropping the last day.
Developer ToolsSQL Server, Oracle, PostgreSQL and MySQL Data Type Mapping Reference
A quick lookup of equivalent data types across four databases, with the gotchas that break ERP migrations.
Developer ToolsERP Data Extract PowerShell to CSV Script Generator
Creates a scheduled-task-ready PowerShell script that runs a read-only SQL query and writes a timestamped CSV with a simple log.
Developer ToolsPCBA BOM Staging Table and Validation SQL Generator
Create a staging table and validation queries to clean an electronic BOM before loading it into an ERP.
More Developer Tools tools
See all- SAP Sales Order ABAP SELECT Generator (VBAK, VBAP, VBFA)
- SAP Sales Order Create BAPI ABAP Generator (BAPI_SALESORDER_CREATEFROMDAT2)
- SAP ABAP Open Items SELECT Generator
- SAP ACDOCA SQL Query Generator
- SAP QM Inspection Lot ABAP SELECT Generator
- SAP Quality Notification Pareto SQL Query Generator
- SAP QM Usage Decision BAPI Skeleton
- ABAP Custom Exception Class Generator
- ABAP Unit Test Class Generator