Excel to SQL turns one sheet of an .xlsx, .xlsm, .xls, .xlsb or .ods workbook into a SQL script: a CREATE TABLE statement plus INSERT statements for MySQL / MariaDB, PostgreSQL, SQL Server or SQLite. The typical job is a supplier's 3,000-row price list that has to become a products table this afternoon, while the database's import wizard wants a CSV or fails on a missing driver. A script runs anywhere you can paste SQL.
How to convert Excel to SQL
- Drop the workbook on the box, or click to browse. Files up to 50MB are read in your browser; nothing is uploaded, and your workbook isn't changed.
- Pick the sheet (the picker appears when more than one sheet holds values) and the database.
- Check the table name, which starts as the sheet name cleaned up ("Orders 2026" becomes
orders_2026). Set the rows per statement (500 by default) and the two boxes, "The first row is the header" and "Include CREATE TABLE".
- Go down the column list. Each column shows its heading, its name in the SQL (you can edit it), a type dropdown with the detected type marked "(detected)", and up to three of its values.
- Read the first 60 lines of SQL and any "Check before you run it" notes, then click "Copy SQL" or "Download .sql". The Orders 2026 sheet of orders.xlsx downloads as
orders_2026 (xlsx.com).sql.
- Run the script in your database's query tool or command line. The converter never connects to a database.
What the SQL looks like
A three-row order sheet with dates shown as dd/mm/yyyy, ZIP codes formatted 00000, currency amounts and one empty cell becomes, for PostgreSQL:
CREATE TABLE "orders_2026" (
"order_id" INTEGER,
"customer" VARCHAR(20),
"order_date" DATE,
"zip" VARCHAR(10),
"amount" DECIMAL(10, 2),
"paid" BOOLEAN
);
INSERT INTO "orders_2026" ("order_id", "customer", "order_date", "zip", "amount", "paid") VALUES
(1001, 'O''Brien Ltd', '2026-03-04', '02134', 1234.5, TRUE),
(1002, 'Zoë Martin', '2026-03-05', '90210', 89.99, FALSE),
(1003, 'Acme', '2026-03-06', '00501', NULL, TRUE);
The apostrophe is doubled, the dates are ISO, ZIP 501 keeps its zeros as '00501' and the empty amount is NULL. The amount is the stored value, 1234.5, without its currency format.
Column names come from the header row as lower snake_case: "Order ID" becomes order_id, "Café" becomes cafe, and "2024 Sales" becomes c_2024_sales. A blank heading, or one in Chinese, becomes column_ plus its column letter.
Types come from the cells. Whole numbers are INTEGER (BIGINT past 2,147,483,647), decimals get a DECIMAL sized to fit, and a date column is DATE, or DATETIME when any cell has a time. Anything mixed is VARCHAR, rounded up to 10, 20, 50, 100 or 255 characters, then TEXT. Every column allows NULL.
How the four databases differ
The same sheet produces different SQL for each database:
| MySQL / MariaDB | PostgreSQL | SQL Server | SQLite |
|---|
| Names quoted with | `backticks` | "double quotes" | [brackets] | "double quotes" |
| Whole numbers | INT | INTEGER | INT | INTEGER |
| Date and time | DATETIME | TIMESTAMP | DATETIME2 | TEXT |
| TRUE/FALSE written as | TRUE / FALSE | TRUE / FALSE | 1 / 0 (BIT) | 1 / 0 |
| Text | VARCHAR | VARCHAR | NVARCHAR, with N'...' literals | TEXT |
| Backslash in text | Doubled | Kept | Kept | Kept |
Quoting every name lets a heading like Order, Group or Select work as a column name; unquoted, each is a reserved word and the CREATE TABLE fails. MySQL reads \t inside a string as a tab, so without the doubling a path like C:\temp arrives mangled. On SQL Server, the N prefix and NVARCHAR are what keep accents and emoji from turning into question marks. SQLite has no date type, so dates go in as ISO text, which still sorts in date order.
Why the rows per statement stop at 1,000
SQL Server caps a VALUES list at 1,000 rows. Go past it and the whole statement fails with error 10738: "The number of row value expressions in the INSERT statement exceeds the maximum allowed number of 1000 row values."
So the choices are 100, 500, 1,000 or one INSERT per row, on every database. One INSERT per row makes a failure point at a single line.
Dates, leading zeros and numbers stored as text
Dates. Excel stores 4 March 2026 as the serial number 46085, and copying the stored value hands the database 46085. The converter writes '2026-03-04' instead, and '2026-03-04 14:30:00' for a date with a time. On SQL Server that becomes '2026-03-04T14:30:00', the form it reads the same way under any language setting, so a British login doesn't swap day and month. Older Mac workbooks count from 1904, and the converter reads each file in its own date system.
Leading zeros. A ZIP code shown as 02134 is often the number 2134 wearing a 00000 format. Load it into an INT column and the zero is gone for good. The converter writes numbers in a zero-padded format (00000, 000-00-0000, (000) 000-0000) as the text Excel shows, which makes the column VARCHAR.
Numbers stored as text. A column of "1,200" and "$5" typed as text comes out as VARCHAR. Set it to a number type and "1,200" becomes 1200, "$5" becomes 5, "12%" becomes 0.12. A code with a leading zero, like 00123, isn't converted: it becomes NULL and is listed, your cue to keep that column as text.
Values that don't fit their column
After a type change, some cells may not fit: text in a number column, 2.5 in a whole-number column. The converter writes each as NULL and lists it under "Check before you run it", with a count per column and up to three examples. Nothing is rounded or cut to fit.
Writing NULL is why one stray "n/a" doesn't sink a 500-row INSERT: PostgreSQL, SQL Server and MySQL in strict mode would refuse the whole statement over that one value. Error cells like #N/A become NULL and are counted too.
Doing it in Excel without a converter
A formula can build each INSERT. With a name in A2 and a date in B2, put this in D2 and fill it down:
="INSERT INTO customers (name, signup_date) VALUES ('"&SUBSTITUTE(A2,"'","''")&"', '"&TEXT(B2,"yyyy-mm-dd")&"');" // SUBSTITUTE doubles apostrophes, TEXT turns the serial number into an ISO date
Copy column D into your query tool. That does for a one-off, but it has gaps: an empty cell becomes '' rather than NULL, and you write the CREATE TABLE and pick every type yourself. The yyyy code in TEXT also changes with Excel's language, so a German copy of Excel needs it rewritten.
Each database has its own import route, and all but SQL Server's want a CSV:
- SQL Server: in SSMS, right-click the database and choose Tasks > Import Data. Reading .xlsx there needs Microsoft's Access Database Engine; the error "The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine" means it's missing, or installed in the other bitness (32-bit vs 64-bit).
- MySQL Workbench: the Table Data Import Wizard takes CSV or JSON, not .xlsx.
- PostgreSQL:
\copy products FROM 'products.csv' WITH (FORMAT csv, HEADER) in psql, into a table you've already created.
- SQLite:
.import --csv products.csv products in the sqlite3 shell.
For a sheet of a few hundred thousand rows, a CSV bulk load is faster than running INSERTs. Excel to CSV writes one from an .xlsx; tick "Unformatted numbers" and dates come out as ISO 8601. The trade-off: that option also writes a 00000-formatted ZIP as 2134.
Limits
- One sheet per script. For several sheets, pick each in turn.
- No constraints. No primary key, NOT NULL, indexes or foreign keys. Add them to the CREATE TABLE before you run it, or with ALTER TABLE afterwards.
- CREATE TABLE and INSERT only. No DROP TABLE, so running the script a second time fails on the CREATE TABLE (untick "Include CREATE TABLE" when the table exists). No UPDATE or upsert. No transaction: with autocommit, the usual default, a failure in the fourth INSERT leaves the first three in the table. Wrap the script in one yourself if that matters.
- Workbooks only. No CSV, no URL and no pasted cells. A file with a password to open is detected, and has to be saved without the password first.
- ASCII column names. A heading in another script becomes
column_c and so on. Rename it on the page.
- Elapsed times come out as text. A [h]:mm cell like 30:15 is written as its displayed text, not TIME.
- A zero in a date cell isn't a date. Excel shows it as 00/01/1900; the converter writes the number 0, which turns the column to text. Set the column to DATE and that cell becomes NULL, and is counted.
- Formatting, notes, images and charts aren't part of the SQL.
Dates typed as text, like "04/03/2026", come out as VARCHAR. Convert Date Format turns them into real Excel dates first, in an .xlsx or .xlsm, reading them in the day-month order you choose; the converter then types that column DATE.
Questions
How do I convert Excel data into SQL insert statements?
Drop the workbook on this page, pick the sheet and your database, and copy the script or download it as a .sql file. You get one CREATE TABLE statement and multi-row INSERTs, with column names taken from the header row and types from the values. Run the script in your database's query tool.
How do I fix 'The number of row value expressions in the INSERT statement exceeds the maximum allowed number of 1000 row values'?
Split the INSERT so no VALUES list has more than 1,000 rows. SQL Server refuses a longer list with error 10738. This converter never writes more than 1,000 rows per statement, and its default is 500.
Why do my Excel dates turn into five-digit numbers in SQL?
Because Excel stores a date as a serial number, so 4 March 2026 is 46085, and a converter that copies the stored value writes that number. This converter writes date cells as ISO text such as '2026-03-04' and types the column DATE (TEXT in SQLite). A date typed as text is still text, though, and comes out as VARCHAR.
How do I keep leading zeros when importing Excel into SQL?
Store the column as text in the database, never as an integer. A ZIP code like 02134 is often the number 2134 with a 00000 format in Excel, and an INT column drops the zero. This converter writes numbers in a zero-padded format as the text Excel shows, so the column becomes VARCHAR and keeps '02134'.
Can MySQL Workbench import an Excel file directly?
No. Its Table Data Import Wizard reads CSV and JSON files, not .xlsx. Save the sheet as CSV first, or run a SQL script with CREATE TABLE and INSERT statements in a query tab instead.
Does the Excel to SQL converter connect to my database or upload my file?
Neither. The workbook is read and the SQL written in your browser, and nothing runs the SQL. You copy or download the script and run it yourself.