{"id":9772,"date":"2025-06-07T06:41:07","date_gmt":"2025-06-07T06:41:07","guid":{"rendered":"http:\/\/www.withdata.com\/blog\/?p=9772"},"modified":"2026-11-12T18:45:31","modified_gmt":"2026-11-12T18:45:31","slug":"4-easy-steps-to-import-excel-data-to-sql-server","status":"publish","type":"post","link":"https:\/\/www.withdata.com\/blog\/xlstosql\/4-easy-steps-to-import-excel-data-to-sql-server.html","title":{"rendered":"Import Excel into SQL Server: Types, IDENTITY and Failed Rows"},"content":{"rendered":"<p>Want to import data from Excel file to  <a href=\"https:\/\/www.microsoft.com\/en-us\/cloud-platform\/sql-server\">SQL Server<\/a> ?<\/p>\n<p>Try Withdata <a href=\"https:\/\/www.withdata.com\/file-to-db\/\">FileToDB<\/a>, a desktop Excel to SQL Server converter for Windows, MacOS, and Linux, Convert Excel to SQL Server, Easy and Fast.<\/p>\n<ul>\n<li>Can run in <span id=\"gui\">GUI<\/span> mode, <a href=\"#convert\">Step by Step<\/a>, just a few mouse clicks.<\/li>\n<li>Can run in <a href=\"\/tools\/file-to-db\/excel-to-mssql-cmd\" target=\"_blank\">Command line<\/a>, for <a href=\"\/tools\/file-to-db\/excel-to-mssql-task\" target=\"_blank\">Scheduled Tasks<\/a> and Streams.<\/li>\n<li>Import Excel to SQL Server locally and <b>privately<\/b>, avoid uploading Excel file(s) to online services.<\/li>\n<li>Support <a href=\"\/tools\/file-to-db\/excel-to-mssql-windows\" target=\"_blank\">Windows<\/a>, <a href=\"\/tools\/file-to-db\/excel-to-mssql-linux\" target=\"_blank\">Linux<\/a>, and <a href=\"\/tools\/file-to-db\/excel-to-mssql-macos\" target=\"_blank\">macOS<\/a>.<\/li>\n<\/ul>\n<p><a href=\"#download-top\" onclick=\"dtv.style.display = 'block';\">Download Withdata FileToDB<\/a>  <a href=\"#download-top\" onclick=\"dtv.style.display = 'block';\"><img decoding=\"async\" src=\"https:\/\/www.withdata.com\/images\/download_3.jpg\" alt=\"Download FileToDB\" width=\"80\" height=\"22\" style=\"max-width:100%;height:auto;\" \/><\/a> <span id=\"dtv\" style=\"display: none;\"><br \/>\n<a href=\"\/download.php?app=FileToDB&#038;ver=win64\">Windows 64 bit<\/a><br \/>\n<a href=\"\/download.php?app=FileToDB&#038;ver=win32\">Windows 32 bit<\/a><br \/>\n<a href=\"\/download.php?app=FileToDB&#038;ver=deb\">Linux .deb (For Debian, Ubuntu) 64 bit<\/a><br \/>\n<a href=\"\/download.php?app=FileToDB&#038;ver=rpm\">Linux .rpm (For Red Hat, Fedora, SUSE) 64 bit<\/a><br \/>\n<a href=\"\/download.php?app=FileToDB&#038;ver=pkg\">MacOS 64 bit<\/a><br \/>\n<\/span><\/p>\n<div style=\"border-left:4px solid #2c7fb8;background:#f4f8fb;padding:12px 16px;margin:18px 0\">\n<p><strong>SQL Server is the strictest of the three about what a spreadsheet may hand it.<\/strong> The import<br \/>\nwizard is four steps; everything that goes wrong happens in the mapping and in the first bad row:<\/p>\n<table style=\"border-collapse:collapse;width:100%\">\n<thead>\n<tr>\n<th style=\"text-align:left;padding:6px 8px;border-bottom:1px solid #cfdbe6\">What goes wrong<\/th>\n<th style=\"text-align:left;padding:6px 8px;border-bottom:1px solid #cfdbe6\">Why<\/th>\n<th style=\"text-align:left;padding:6px 8px;border-bottom:1px solid #cfdbe6\">Fix<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"padding:6px 8px\">The imported ids are not the ids you sent<\/td>\n<td style=\"padding:6px 8px\">The column is an <code>IDENTITY<\/code>: SQL Server generates its own sequence and ignores the values<\/td>\n<td style=\"padding:6px 8px\">Import into a plain <code>int<\/code> column, or <code>SET IDENTITY_INSERT \u2026 ON<\/code> for the load<\/td>\n<\/tr>\n<tr>\n<td style=\"padding:6px 8px\">Chinese text arrives as <code>?<\/code><\/td>\n<td style=\"padding:6px 8px\">The column is <code>varchar<\/code> (single-byte code page) rather than <code>nvarchar<\/code><\/td>\n<td style=\"padding:6px 8px\">Use <code>nvarchar<\/code>\/<code>nvarchar(max)<\/code> for anything that is not plain ASCII<\/td>\n<\/tr>\n<tr>\n<td style=\"padding:6px 8px\">Dates lose their seconds \/ come back as <code>1900-01-01<\/code><\/td>\n<td style=\"padding:6px 8px\"><code>datetime<\/code> rounds to 3&nbsp;ms and starts in 1753; a bad conversion falls back to the default<\/td>\n<td style=\"padding:6px 8px\"><code>datetime2<\/code> for new tables; check the mapping for the date column before running<\/td>\n<\/tr>\n<tr>\n<td style=\"padding:6px 8px\"><code>Bulk load data conversion error (truncation)<\/code> for the whole file<\/td>\n<td style=\"padding:6px 8px\"><code>BULK INSERT<\/code>\/<code>bcp<\/code> reject the batch on the first conversion error unless <code>MAXERRORS<\/code> is raised<\/td>\n<td style=\"padding:6px 8px\">Stage into <code>nvarchar(max)<\/code> columns, then <code>CAST<\/code> into the real table<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<h2 id=\"import\">Import data from Excel to SQL Server in 4 steps<\/h2>\n<p><a href=\"#source\">Choose Excel file<\/a> -> <a href=\"#target\">Set SQL Server table<\/a> -> <a href=\"#preview\">Preview SQL Server table<\/a> -> <a href=\"#do\">Import Excel to SQL Server<\/a><\/p>\n<p> Choose SQL Server and logon.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.withdata.com\/images\/logon\/choose_sql-server_logon.png\" alt=\"convert Excel file to SQL Server table - Choose SQL Server and logon\" width=\"430\" height=\"442\" style=\"max-width:100%;height:auto;display:block;\" \/><\/p>\n<p> Click &#8220;Wizard &#8211; 1 File To 1 Table&#8221; for &#8220;Excel to SQL Server&#8221;.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.withdata.com\/images\/file-to-db\/task-window.png\" alt=\"convert Excel file to SQL Server table - task window\" width=\"722\" height=\"399\" style=\"max-width:100%;height:auto;display:block;\" loading=\"lazy\" decoding=\"async\" \/><\/p>\n<p> Select the &#8220;Excel&#8221; file type.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.withdata.com\/images\/file-to-db\/select-file-type-excel.png\" ALT=\"Import file data to database table - select file type\" width=\"547\" height=\"236\" style=\"max-width:100%;height:auto;display:block;\" loading=\"lazy\" decoding=\"async\"><\/p>\n<p>then show the wizard.<\/p>\n<p id=\"source\"><b>Step #1<\/b>. Open an Excel file.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.withdata.com\/images\/file-to-db\/wizard-import-file-source-file-excel.png\" ALT=\"Import Excel Data To SQL Server - open Excel file\" width=\"724\" height=\"573\" style=\"max-width:100%;height:auto;display:block;\" loading=\"lazy\" decoding=\"async\"><\/p>\n<p id=\"target\"><b>Step #2<\/b>. Select a SQL Server table and config fields.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.withdata.com\/images\/file-to-db\/wizard-import-dest-table-no-schema.png\" ALT=\"Load Data From Excel To SQL Server - select table\" width=\"724\" height=\"573\" style=\"max-width:100%;height:auto;display:block;\" loading=\"lazy\" decoding=\"async\"><\/p>\n<p id=\"preview\"><b>Step #3<\/b>. Preview SQL Server table.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.withdata.com\/images\/file-to-db\/wizard-import-preview-excel.png\" ALT=\"Transfer Data From Excel To SQL Server - preview\" width=\"724\" height=\"573\" style=\"max-width:100%;height:auto;display:block;\" loading=\"lazy\" decoding=\"async\"><\/p>\n<p id=\"do\"><b>Step #4<\/b>. Import Excel to SQL Server.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.withdata.com\/images\/file-to-db\/wizard-import-convert-excel.png\" ALT=\"Convert Data From Excel To SQL Server - import data\" width=\"724\" height=\"573\" style=\"max-width:100%;height:auto;display:block;\" loading=\"lazy\" decoding=\"async\"><\/p>\n<hr style=\"clear: both;\" \/>\n<p>More about <a href=\"\/tools\/file-to-db\/excel-to-mssql\">Excel to SQL Server converter<\/a><\/p>\n<div id=\"download-bottom\" style=\"clear: both;\">\n<p>Download Withdata FileToDB<a href=\"#download-bottom\" onclick=\"dbv.style.display = 'block';\"><img decoding=\"async\" src=\"https:\/\/www.withdata.com\/images\/btn_download_green.png\" alt=\"Download FileToDB\" width=\"165\" height=\"50\" style=\"max-width:100%;height:auto;\" loading=\"lazy\" decoding=\"async\" \/><\/a> <span id=\"dbv\" style=\"display: none;\"><br \/>\n<a href=\"\/download.php?app=FileToDB&#038;ver=win64\">Windows 64 bit<\/a><br \/>\n<a href=\"\/download.php?app=FileToDB&#038;ver=win32\">Windows 32 bit<\/a><br \/>\n<a href=\"\/download.php?app=FileToDB&#038;ver=deb\">Linux .deb (For Debian, Ubuntu) 64 bit<\/a><br \/>\n<a href=\"\/download.php?app=FileToDB&#038;ver=rpm\">Linux .rpm (For Red Hat, Fedora, SUSE) 64 bit<\/a><br \/>\n<a href=\"\/download.php?app=FileToDB&#038;ver=pkg\">MacOS 64 bit<\/a><br \/>\n<\/span><\/p>\n<\/div>\n<p><!-- wd-cta:xl2mssql --><\/p>\n<h2>Excel type to SQL Server type<\/h2>\n<p>Two decisions matter more than the rest: <code>nvarchar<\/code> instead of <code>varchar<\/code>, and<br \/>\n<code>datetime2<\/code> instead of <code>datetime<\/code>. The rest is sizing.<\/p>\n<table style=\"border-collapse:collapse;width:100%\">\n<thead>\n<tr>\n<th style=\"text-align:left;padding:6px 8px;border-bottom:1px solid #cfdbe6\">In the sheet<\/th>\n<th style=\"text-align:left;padding:6px 8px;border-bottom:1px solid #cfdbe6\">In SQL Server<\/th>\n<th style=\"text-align:left;padding:6px 8px;border-bottom:1px solid #cfdbe6\">Watch out for<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"padding:6px 8px\">Text with accents or CJK<\/td>\n<td style=\"padding:6px 8px\"><code>nvarchar(n)<\/code>, <code>nvarchar(max)<\/code><\/td>\n<td style=\"padding:6px 8px\"><code>varchar<\/code> stores one byte per character in a code page; anything outside it is lost as <code>?<\/code><\/td>\n<\/tr>\n<tr>\n<td style=\"padding:6px 8px\">Date and time<\/td>\n<td style=\"padding:6px 8px\"><code>datetime2(0)<\/code> or <code>date<\/code><\/td>\n<td style=\"padding:6px 8px\"><code>datetime<\/code> rounds to .000\/.003\/.007 and cannot hold dates before 1753.<\/td>\n<\/tr>\n<tr>\n<td style=\"padding:6px 8px\">Money<\/td>\n<td style=\"padding:6px 8px\"><code>decimal(12,2)<\/code><\/td>\n<td style=\"padding:6px 8px\">Not <code>float<\/code>; and <code>money<\/code> is a legacy type with its own quirks.<\/td>\n<\/tr>\n<tr>\n<td style=\"padding:6px 8px\">Numbers from the sheet<\/td>\n<td style=\"padding:6px 8px\"><code>int<\/code>, <code>bigint<\/code><\/td>\n<td style=\"padding:6px 8px\">A cell formatted as text may arrive as <code>'1,234'<\/code> and fail the cast.<\/td>\n<\/tr>\n<tr>\n<td style=\"padding:6px 8px\">True\/false column<\/td>\n<td style=\"padding:6px 8px\"><code>bit<\/code><\/td>\n<td style=\"padding:6px 8px\">Accepts <code>1\/0<\/code>; the strings need converting first.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>Identifiers: brackets and case-insensitive collation<\/h2>\n<p>SQL Server quotes identifiers with <code>[square brackets]<\/code>, and by default the collation is<br \/>\ncase-<em>insensitive<\/em>, so <code>OrderDate<\/code> and <code>orderdate<\/code> are the same column &mdash; which<br \/>\nis convenient until two sheets produce headers that differ only in case and get merged into one column.<br \/>\nColumn names with spaces need the brackets everywhere, and a header that is a keyword<br \/>\n(<code>order<\/code>, <code>key<\/code>, <code>percent<\/code>) does too; renaming during the mapping step is<br \/>\nstill cheaper.<\/p>\n<h2>Finding the rows that fail<\/h2>\n<p>Bulk loading in SQL Server is fast and unforgiving: <code>BULK INSERT<\/code> and <code>bcp<\/code> stop at<br \/>\nthe first conversion error unless <code>MAXERRORS<\/code> is set, and a failed batch inside a transaction rolls<br \/>\nback as a unit. Raising <code>MAXERRORS<\/code> buys you a partial load &mdash; which is useful only if you can<br \/>\ntell which rows arrived.<\/p>\n<ul>\n<li><b>Stage into <code>nvarchar(max)<\/code><\/b> and convert with explicit <code>CAST<\/code>\/<code>TRY_CAST<\/code>:<br \/>\n<code>TRY_CAST<\/code> returns <code>NULL<\/code> instead of failing, so a query can list the rows it could not read.<\/li>\n<li><b>Keep the sheet row number<\/b> as a column in staging; it is the only handle back to the spreadsheet.<\/li>\n<li><b>Load in batches<\/b> so one bad row costs a batch, and check <code>@@ROWCOUNT<\/code> against the number of<br \/>\nrows you sent &mdash; the cheapest possible reconciliation.<\/li>\n<\/ul>\n<h2>Many sheets, many files, every night<\/h2>\n<p>Append every sheet to the same table, or create one table per sheet when the sheets are different entities;<br \/>\na folder of workbooks runs as a single job. The in-tool session can be saved and scheduled, which is what turns<br \/>\n&#8220;the monthly import&#8221; into a task rather than a ritual.<\/p>\n<p>Other directions: <a href=\"https:\/\/www.withdata.com\/tools\/db-to-file\/mssql-to-excel\">SQL Server to Excel<\/a>,<br \/>\nand the same guide for the other two databases &mdash;<br \/>\n<a href=\"https:\/\/www.withdata.com\/blog\/xlstopg\/4-easy-steps-to-import-excel-data-to-postgresql.html\">PostgreSQL<\/a><br \/>\nand <a href=\"https:\/\/www.withdata.com\/blog\/xlstomy\/4-easy-steps-to-import-excel-data-to-mysql.html\">MySQL<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Want to import data from Excel file to SQL Server ? Try Withdata FileToDB, a desktop Excel to SQL Server converter for Windows, MacOS, and Linux, Convert Excel to SQL Server, Easy and Fast. Can run in GUI mode, Step by Step, just a few mouse clicks. Can run in Command line, for Scheduled Tasks [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[93],"tags":[15,6,1321],"class_list":["post-9772","post","type-post","status-publish","format-standard","hentry","category-xlstosql","tag-excel","tag-import","tag-sql-server"],"_links":{"self":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts\/9772","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/comments?post=9772"}],"version-history":[{"count":12,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts\/9772\/revisions"}],"predecessor-version":[{"id":45964,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts\/9772\/revisions\/45964"}],"wp:attachment":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/media?parent=9772"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/categories?post=9772"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/tags?post=9772"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}