Load Excel Data Into a SQL Table: A Practical Guide

How-to basics · Updated November 21, 2026

To load Excel data into a SQL table, first clean and check the worksheet, then import it with your database’s import wizard or save it as a CSV file and use the database’s bulk-loading tools. For a repeatable process, use an ETL tool, script, or connector; the best method depends on your database, data size, and how often the import must run.

What loading Excel data into SQL involves

Excel is a workbook format, while SQL databases store information in tables with defined columns and data types. Loading a worksheet means transferring its rows into a table, mapping each spreadsheet column to a database column, and deciding how to handle values that do not fit the target schema. A workbook may contain several sheets, formulas, formatting, merged cells, and notes; a SQL table holds structured values, not the full workbook experience.

For example, a worksheet with OrderID, OrderDate, Customer, and Amount could become a table with an integer identifier, a date, text, and a decimal amount. Before importing, decide whether the destination table already exists or should be created, whether existing rows should be retained, and whether an imported row with a duplicate key should be rejected, updated, or otherwise handled. These choices matter more than the file extension.

Choose an import method

For an occasional transfer into Microsoft SQL Server, SQL Server Management Studio (SSMS) has an Import Data wizard that can read Excel workbooks when the appropriate Excel data provider is available. In SSMS, right-click the destination database, choose Tasks > Import Data…, and follow the wizard to select the source, destination, and column mappings. Exact options and provider availability depend on the installed SQL Server and Office components.

If the workbook can be represented as plain rows and columns, CSV is often simpler and more portable. In Excel for Microsoft 365 on Windows, use File > Save As and choose CSV UTF-8 (Comma delimited) (*.csv) when available. CSV stores one table-like sheet as text; it does not preserve formulas, formatting, multiple sheets, or Excel data types. In SSMS, the Import Flat File wizard is an option for CSV files: right-click the database, choose Tasks > Import Flat File…, and review the detected column definitions before finishing.

Other database platforms have their own tools. MySQL Workbench provides a table data import workflow for CSV files, while PostgreSQL users commonly load CSV with the psql \\copy command or a client’s import feature. A database administrator may also use an ETL product or a programming library to read XLSX and write rows through a database driver. Do not assume SQL Server’s wizard paths or settings apply to MySQL, PostgreSQL, or a cloud database.

  • One-time, modest import: use the platform’s wizard and inspect its column mappings.
  • Cross-platform transfer: export a clean CSV, then use the destination database’s supported loader.
  • Recurring or large imports: use a scripted or managed pipeline that can validate, log, and rerun the process safely.

Prepare the worksheet before importing

Make a copy of the workbook and prepare a single rectangular data range. Use one header row with unique, descriptive names; remove title rows, subtotal rows, blank spacer columns, and merged cells from the data area. Each column should represent one kind of value, and each row should represent one record. If a worksheet mixes detail rows and summary calculations, separate them before loading rather than hoping an importer will infer which rows belong in the table.

Check for values that look alike but are stored differently. An account number such as 00127 should usually be treated as text if its leading zeros are meaningful; importing it as a number can turn it into 127. Dates can be ambiguous when a file moves between regional settings, and Excel may store dates as serial numbers even when they display as dates. Confirm the intended date format and inspect the imported result. For monetary or measured values, select a suitable decimal precision rather than relying on a guess based on a few rows.

Excel formulas deserve special attention. A CSV export generally contains the displayed or calculated values rather than the formulas as executable SQL logic, and a database import does not recreate Excel’s calculation model. Recalculate the workbook if current formula results are required, then verify that the values exported are the ones you intend to store.

Create or map the SQL table

Before starting the import, define the destination schema where possible. A table should have column names, data types, and constraints that match the data and its future use. For a simple SQL Server example, a destination might be defined as follows:

CREATE TABLE dbo.OrdersImport (
    OrderID int NOT NULL,
    OrderDate date NULL,
    Customer nvarchar(100) NULL,
    Amount decimal(12, 2) NULL,
    CONSTRAINT PK_OrdersImport PRIMARY KEY (OrderID)
);

This example assumes order identifiers are unique integers, customer names need Unicode text, and amounts have two decimal places. Those assumptions must be checked against the real data; another database uses different type names and syntax. If the wizard creates a table automatically, inspect and adjust its choices. Automatically inferred types can be too short, too broad, or wrong when early rows do not represent later values.

Map every source column deliberately. Decide whether blank cells should become SQL NULL, empty text, or a default value; these are not always interchangeable. Check whether identifiers need a primary key, whether foreign keys refer to existing records, and whether a destination column permits NULLs. If a table already contains production data, do not choose an option that replaces or truncates it unless that is explicitly intended.

Import the data and verify it

In a wizard, select the workbook or CSV, choose the worksheet or file range, select the destination database, and review the preview and column mappings. Run the import and read the completion messages, warnings, and rejected-row details. A successful wizard message does not prove the values are semantically correct: it only indicates that the operation completed according to the tool’s rules.

After loading, compare the row count with the expected number of data rows, allowing for any intentionally excluded headers or blank rows. Inspect representative records, including the first and last rows, rows with missing values, long text, unusual dates, and values near numeric limits. Check for duplicate identifiers and confirm that important totals match an independent calculation from the source. For recurring imports, record the file name, time, row counts, and failures so a later run can be investigated.

A staging table is useful when the source is unreliable or the destination is important. Load the raw values into a temporary or staging table first, validate and transform them, then insert valid rows into the final table. This separates file-reading problems from business-rule checks and reduces the chance of partially mixing bad source data with trusted records. Where supported, use a transaction or an all-or-nothing load strategy for the final step.

Common errors and practical fixes

  • Excel provider or driver unavailable: the database wizard may require an Excel provider that is not installed or does not match the wizard’s 32-bit or 64-bit environment. Install an approved compatible provider or export to CSV instead.
  • Truncated or rejected text: the destination column may be too short, or a tool may infer its size from early rows. Inspect the longest values and set an appropriate text length before importing.
  • Dates or numbers change: regional separators, mixed formats, currency symbols, and text-formatted cells can lead to conversion errors. Normalize the source and review the database’s parsed values.
  • Leading zeros disappear: values that are identifiers rather than quantities should be imported as text, not numeric columns.
  • Duplicate key or constraint failures: the destination may already contain the same key, or the source itself may have duplicates. Identify the intended update or deduplication rule instead of disabling constraints without review.
  • Import stops partway through: check the tool’s error output and whether it committed rows incrementally. Retry only after determining what was already inserted, to avoid creating duplicates.

Security, access, and repeatability

Use a database account with only the permissions required for the task, such as permission to insert into the intended table. Avoid embedding passwords in shared workbooks or scripts. Treat imported data as untrusted: spreadsheet cells can contain unexpected text, and sensitive information should be handled according to the organization’s access and retention rules. When a script builds SQL statements from cell values, use parameterized queries rather than concatenating values into SQL text; this helps prevent malformed input and SQL injection.

For repeated jobs, document the source location, expected columns, encoding, schema, and behavior when a file is missing or contains invalid rows. Add validation before writing to the target, and make reruns safe where possible—for example, by using a batch identifier, a staging table, or a carefully designed upsert supported by the database. Test the process on a copy or nonproduction database before scheduling it against important data.

CSV, direct workbook import, or an automated pipeline?

Direct workbook import is convenient when the source is an XLSX file and the database tool can read it, but it can depend on installed drivers and workbook layout. CSV avoids many provider dependencies and is easy to inspect, but it loses workbook features and can be awkward when values contain commas, line breaks, or inconsistent encodings. A proper CSV reader handles quoting rules; splitting each line on commas with a homemade script does not reliably parse every valid CSV file.

An automated pipeline is usually the better fit when imports recur, involve several files, require transformations, or must produce an audit trail. It costs more effort to build and maintain than a one-off wizard import, but can enforce consistent validation and produce actionable error reports. For a small one-time job, automation may be unnecessary. Choose based on frequency, volume, risk, and the consequences of a silent error—not only on how quickly the first import can be completed.

Frequently Asked Questions

Can I import an Excel file directly into SQL?
Often, yes. Some database tools read XLSX directly, including SQL Server’s Import Data wizard when its required provider is installed. If direct reading is unavailable or unreliable, save the relevant sheet as CSV and use the database’s import tool.

Can I load an Excel file into SQL Server without SSMS?
Yes. You can use SQL Server’s import/export tooling, an ETL product, or a program that reads the workbook and writes to SQL Server through a supported driver. The right choice depends on whether this is a one-time transfer or a repeatable job.

Does importing Excel formulas store the formulas in SQL?
Usually not as working Excel formulas. Imports typically store cell values, often the calculated results available in the workbook or exported CSV. If a calculation must be maintained, implement its logic in the database or application as appropriate.

How do I keep leading zeros when importing?
Set the source and destination column to text when the zeros are part of an identifier, such as a ZIP code or account code. Confirm the values in the destination; once a value has been imported as a number and its zeros discarded, they cannot be recovered without another source of the original value.

Is it safe to import straight into a production table?
It can be, but only when the schema, data, permissions, and duplicate-handling rules are understood. For uncertain files, import into a staging table, validate the rows, and then transfer approved data into production.

Related

Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.

More in How-to basics

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.