DataSwitch Pro Private, in-browser data converter

How to Import Excel Data into a SQL Database

By the DataSwitch Pro team · · 4 min read

Quick answer

To import Excel into a SQL database, first clean the sheet (one header row, one record per row, no merged cells), create a table with suitable column types, then load the data: save the sheet as CSV UTF-8 and use your database's bulk loader, use SQL Server's Import Wizard, or generate INSERT statements from the .xlsx with an Excel to SQL converter. Check dates, empty cells and ID columns after loading.

Spreadsheets are where data starts; databases are where it becomes useful to applications. The move is straightforward if the sheet is shaped like a table and the column types are chosen deliberately.

Step 1: Shape the sheet like a table

Step 2: Choose column types

Option A: Generate INSERT statements

  1. Open the Excel to SQL converter and drop the .xlsx file; choose the sheet.
  2. Select the dialect — MySQL, PostgreSQL, SQL Server or SQLite — and type the table name.
  3. Tick Add SQL CREATE TABLE for a starting table definition, and Empty cells as NULL if blanks should be NULL.
  4. Review the generated types, then run the script in phpMyAdmin, DBeaver, pgAdmin, SSMS or the command line.

This works anywhere you can run SQL, including shared hosting where file-based import is disabled.

Option B: Save as CSV and bulk load

For large sheets, save as File → Save As → CSV UTF-8 (Comma delimited) and use the database's loader — LOAD DATA, \copy, BULK INSERT or .import. The exact commands are in how to import a CSV file into SQL. Two warnings: Excel exports what each cell displays, so a price formatted as “€12” or a date shown as “Nov 20” is exported that way; and some regional settings produce semicolon-separated files. If you need a specific delimiter, export with Excel to CSV instead.

Option C: SQL Server Import and Export Wizard

SQL Server can read .xlsx directly: in SSMS, right-click the database and choose Tasks → Import Data, then select Microsoft Excel as the source. The wizard needs the Microsoft Access Database Engine (ACE) driver, whose 32-bit or 64-bit version must match the wizard you run — a frequent source of “provider is not registered” errors. If that gets in the way, use Option A or B.

After importing: check these

Keeping the sheet and the table in sync

A one-off import is easy; repeated imports of an updated sheet need a key. Give each row a stable ID column, import into a staging table, then use INSERT ... ON DUPLICATE KEY UPDATE (MySQL), INSERT ... ON CONFLICT (PostgreSQL, SQLite) or MERGE (SQL Server) to update existing rows and add new ones. If the data changes often, consider making the database the source of truth and exporting to Excel for viewing — see exporting SQL results to CSV.

Try it on your own file. Free, private, and processed in your browser.

Frequently asked questions

Are Excel formulas imported?

No. Only the calculated values are exported; databases store data, not spreadsheet formulas.

How do I import several sheets?

Import each sheet into its own table. In a converter, choose each sheet in turn; in Python, pd.read_excel(file, sheet_name=None) reads all of them.

Why do my dates import as numbers like 45000?

The cells held Excel serial numbers without a date format. Format the column as Date in Excel, or convert in SQL: serial 45000 is 15 March 2023.

Can I import .xls (Excel 97-2003) files?

Many tools only read .xlsx. Open the file in Excel or LibreOffice and save it as .xlsx first.

More guides