1xA2ZOne Data. Any Format.
Live syncLocal-first · no data upload

Convert Excel to SQL

Import your Excel file or paste copied cells, then open the SQL tab. You get CREATE TABLE and INSERT statements for the database you pick; this page starts on SQL Server.

Runs entirely in your browser. Your data is never uploaded. Tiếng Việt

01

Spreadsheet

SheetsExcelCSVTSV
✦ Quick pasteSheets / Excel, CSV, TSV, Markdown, JSON, HTML, LaTeX, wiki…
0 rows · 0 columnsSelected cell: A1
02

Live Output

Markdowntwo-way
SyncedEdit directly; the table on the left updates itself
0 characters
Every change is processed right in your browserReady · LocalUTF-8 · by xuanhieu.org

When you need to convert Excel to SQL

You turn Excel into SQL when you need to load a list into a database quickly without building an import tool. What goes wrong is names with apostrophes like O'Brien, column names with spaces or accents, and differences between database engines. The output is one-way SQL: you can export it, but the tool cannot read SQL back.

How to do it

  1. Press Import file and choose an .xlsx file, or copy a range in Excel, paste it into Quick paste and press Load into table ↵.
  2. Check the grid. Only the first sheet is read, and you get displayed values, not formulas.
  3. Open the SQL tab and ⚙ Options: type the table name, choose the database, and decide on CREATE TABLE and whether to merge the inserts.
  4. Press Copy result to run it in your query tool, or Download file to save an .sql file.

A real example

On SQL Server, column names sit in square brackets and the type is NVARCHAR(MAX). O'Brien & Co becomes O''Brien & Co because apostrophes are doubled, and numbers such as 120 stay quoted strings.

Input · Cells in Excel

CodeBrandQtyLocation
P-100O'Brien & Co120Shelf A
P-101L'Oréal45Shelf B
P-102Dell8Shelf A

Result · SQL

CREATE TABLE [stock] (
  [Code] NVARCHAR(MAX),
  [Brand] NVARCHAR(MAX),
  [Qty] NVARCHAR(MAX),
  [Location] NVARCHAR(MAX)
);
INSERT INTO [stock] ([Code], [Brand], [Qty], [Location]) VALUES
  ('P-100', 'O''Brien & Co', '120', 'Shelf A'),
  ('P-101', 'L''Oréal', '45', 'Shelf B'),
  ('P-102', 'Dell', '8', 'Shelf A');

Options worth changing

Database
This sets how identifiers are quoted: square brackets for SQL Server, backticks for MySQL and MariaDB, double quotes for standard SQL, PostgreSQL and SQLite. MySQL also escapes backslashes.
Table name
Set the real target table name, or the INSERT runs against the default name. You can also fix it quickly by hand in the SQL file.
Include CREATE TABLE
Untick it when the table already exists with its own types and primary key and you only need the data.
Batch INSERT
On gives one multi-row VALUES statement, tidier than many single ones. Off lets you run or debug row by row.

Common problems

Limits

Frequently asked questions

Will an apostrophe in a name break the statement?

No. Apostrophes inside values are doubled, so O'Brien becomes O''Brien and the string is not cut short.

I use MySQL. What should I pick?

Choose MySQL / MariaDB under Database. Column names get backticks and backslashes in values are escaped.

Do Excel numbers become numeric columns?

No. Every value is written as a quoted string and every column is text. Change the column types after loading if you need arithmetic.

Is my Excel file uploaded?

No. The file is read and the SQL is generated in your browser.

What about workbooks with several sheets?

Only the first sheet is loaded. Move the one you need to the front, or copy its cells and paste into Quick paste.

Related conversions

1xA2Z · Guide

Table statistics