Skip to content

Convert Excel to SQL Server

Drop your Excel file to get a SQL Server script with CREATE TABLE and INSERT statements. Each column gets a type, and every fix is listed with its row and column.

Your file
xlsxclientes_2024.xlsxSample file, 7 kB
Your database

4 rows converted, 10 fixes, none rejected

Show
The first rows of clientes_2024.xlsx, with each fix marked
Row
500127Peña Muñoz0123403/02/2024sí1.234,50
600128José Ángel0987015/02/2024noN/A
700129Zoë Ortíz4410029/02/2024sí-12,00
800130Ñuño Castañeda0670011/03/2024no980,75
-- Written by IntoSQL for SQL Server.

SET NOCOUNT ON;
BEGIN TRANSACTION;

CREATE TABLE clientes_2024 (
    no_cliente nvarchar(8) NOT NULL, -- Nº Cliente
    nombre nvarchar(16) NOT NULL,
    c_p nvarchar(8) NOT NULL, -- C.P.
    alta date NOT NULL,
    activo bit NOT NULL,
    saldo decimal(6,2)
);

INSERT INTO clientes_2024 (no_cliente, nombre, c_p, alta, activo, saldo) VALUES
(N'00127', N'Peña Muñoz', N'01234', '2024-02-03', 1, 1234.50),
(N'00128', N'José Ángel', N'09870', '2024-02-15', 0, NULL),
(N'00129', N'Zoë Ortíz', N'44100', '2024-02-29', 1, -12.00),
(N'00130', N'Ñuño Castañeda', N'06700', '2024-03-11', 0, 980.75);

COMMIT TRANSACTION;

Fixes

  1. The header is on row 4; the rows above it were left out.
  2. Row 9 ("TOTAL") is a total, so it was left out.
  3. Column "Nº Cliente" is named no_cliente so SQL Server reads it without quotes.
  4. Column "C.P." is named c_p so SQL Server reads it without quotes.
  5. Leading zeros kept in "Nº Cliente": 00127 stays 00127, stored as text.
  6. Leading zeros kept in "C.P.": 01234 stays 01234, stored as text.
  7. 15/02/2024 proves the dates in "Alta" are day-first, so 03/02/2024 is read as 2024‑02‑03.
  8. "Activo" holds yes and no words (sí, no), stored as boolean.
  9. Numbers in "Saldo" use a decimal comma: 1.234,50 is read as 1234.50.
  10. N/A in "Saldo" read as empty (1 of 4 values).

Your file is converted on this computer and never uploaded.

Other samples:

From Excel to SQL Server, column by column

The sample above, clientes_2024.xlsx, as IntoSQL writes it for SQL Server: what each column holds in the file, the type it gets and how its first value lands in the script.

In the fileFirst valueColumnSQL Server typeIn the script
Nº Cliente00127no_clientenvarchar(8)N'00127'
NombrePeña Muñoznombrenvarchar(16)N'Peña Muñoz'
C.P.01234c_pnvarchar(8)N'01234'
Alta03/02/2024altadate'2024-02-03'
Activosíactivobit1
Saldo1.234,50saldodecimal(6,2)1234.50

Load the script into SQL Server

The download is a plain .sql file. Run it with SQL Server's own tools.

From a terminal

sqlcmd -S localhost -d mydb -f 65001 -i clientes_2024.sql_server.sql

-f 65001 reads the file as UTF-8, so accents and ñ arrive as written.

From a database tool

In SQL Server Management Studio or Azure Data Studio, open the file and choose Execute.

What to know about Excel files and SQL Server

What IntoSQL reads in Excel files

  • The header row is found even when titles or notes sit above it, and a totals row at the end is left out.
  • Dates stored as Excel serial numbers become real dates, in both the 1900 and the 1904 date systems.
  • Codes with leading zeros, like 00127, stay text. When a workbook has several sheets, you pick the sheet.

What to know about SQL Server

  • Text is nvarchar with N'...' values, so accents survive; text over 4000 characters becomes nvarchar(max).
  • Yes and no values become bit, and dates with an offset become datetimeoffset.
  • Long values are written in pieces, so sqlcmd and SQL Server Management Studio accept the script.

How each kind of value is stored in SQL Server

ValueSQL Server
Yes and nobit
Whole numbersint
Large whole numbersbigint
Decimalsdecimal(p,s)
Floating-point numbersfloat
Datesdate
Times of daytime
Dates with a timedatetime2
Dates with a time and offsetdatetimeoffset
Textnvarchar(n)nvarchar(max)

Questions about Excel to SQL Server

Not answered here? Write to us from the contact page and a person replies. Contact page

How do I convert Excel to SQL Server?

Drop your file on the converter at the top of this page. It finds the header, reads every value and writes the SQL Server script, listing each fix it made. Download the script and run it with sqlcmd.

Which sheet of the workbook is converted?

The first visible sheet. When a workbook has more than one, a Sheet option appears, so you can pick another.

Which SQL Server types does it use?

Yes and no values become bit, whole numbers int, decimals decimal(p,s), dates date, dates with a time datetime2 and text nvarchar(n). Sizes come from the longest value in each column.

Does it keep leading zeros in SQL Server?

Yes. A code such as 00127 stays text, so SQL Server stores it as nvarchar(8) and the script writes it as N'00127'.

Can it load the data into SQL Server without a script?

No. Download the script and run it with sqlcmd. Loading without a script works for PostgreSQL, MySQL, MariaDB and SQLite, from the desktop app or the command line.

How big can the Excel file be?

In the browser, a workbook is read whole, so the limit is the memory the browser gives this page. The desktop app and the command line take workbooks of any size; on an Apple M4 laptop the command line converts a 117 MB workbook of a million rows in about a second.