{"id":23497,"date":"2024-01-01T06:41:00","date_gmt":"2024-01-01T05:41:00","guid":{"rendered":"https:\/\/expert-only.com\/?p=23497"},"modified":"2024-02-23T11:31:10","modified_gmt":"2024-02-23T10:31:10","slug":"how-to-import-an-excel-file-into-sql-server-using-python","status":"publish","type":"post","link":"https:\/\/expert-only.com\/en\/python\/how-to-import-an-excel-file-into-sql-server-using-python\/","title":{"rendered":"How To Import An Excel File Into SQL Server Using Python?"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\" id=\"h-a-step-by-step-tutorial-on-importing-data-from-excel-documents-into-sql-server-databases-using-few-lines-of-powerful-python-scripts\"><em>A step-by-step tutorial on importing data from Excel documents into SQL Server databases using few lines of powerful Python scripts.<\/em><\/h4>\n\n\n\n<p>In this tutorial, we will learn how to import data from an Excel file into a SQL Server table using Python code. We&#8217;ll use three main stages: create an Excel file containing sample data, create a table in SQL Server that fits our data structure, and import the Excel data into the SQL Server table. To achieve this, we will employ the power of Python&#8217;s openpyxl and pyodbc libraries. By the end of this programming tutorial, you will master importing data from Excel documents into a SQL Server database, using the versatility and efficiency of Python.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 ez-toc-wrap-center counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/expert-only.com\/en\/python\/how-to-import-an-excel-file-into-sql-server-using-python\/#1-prepare-a-sample-excel-file-with-sample-data\" >1. Prepare a sample Excel file with sample data<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/expert-only.com\/en\/python\/how-to-import-an-excel-file-into-sql-server-using-python\/#2-create-a-sql-server-table-to-store-the-excel-data\" >2. Create a SQL Server table to store the Excel data<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/expert-only.com\/en\/python\/how-to-import-an-excel-file-into-sql-server-using-python\/#3-python-script-to-import-data-from-excel-into-sql-server\" >3. Python script to import data from Excel into SQL Server<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\" id=\"h-1-prepare-a-sample-excel-file-with-sample-data\"><span class=\"ez-toc-section\" id=\"1-prepare-a-sample-excel-file-with-sample-data\"><\/span>1. Prepare a sample Excel file with sample data<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>To demonstrate how to import data from an Excel file to a SQL Server table using Python, we first need a sample Excel file with data. In this example, we will use an Excel file named <em>employees.xlsx<\/em> containing employee data with the following headers.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>ID<\/li>\n\n\n\n<li>Name<\/li>\n\n\n\n<li>Department<\/li>\n\n\n\n<li>Salary<\/li>\n<\/ul>\n\n\n\n<p>Here&#8217;s a sample of the data for the Excel file, technically you simply need to copy and paste it into an <a href=\"https:\/\/expert-only.com\/en\/excel\/create-excel-table\/\"><strong>Excel table<\/strong><\/a>, in a sheet of a new Excel document.<\/p>\n\n\n\n<figure class=\"wp-block-table is-style-stripes\"><table><thead><tr><th>ID<\/th><th>Name<\/th><th>Department<\/th><th>Salary<\/th><\/tr><\/thead><tbody><tr><td>1<\/td><td>John Smith<\/td><td>Sales<\/td><td>50000<\/td><\/tr><tr><td>2<\/td><td>Jane Doe<\/td><td>Marketing<\/td><td>60000<\/td><\/tr><tr><td>3<\/td><td>Bob Johnson<\/td><td>IT<\/td><td>70000<\/td><\/tr><tr><td>4<\/td><td>Alice Wong<\/td><td>HR<\/td><td>55000<\/td><\/tr><\/tbody><\/table><figcaption class=\"wp-element-caption\"><em>Sample data for Excel to import into SQL Server<\/em><\/figcaption><\/figure>\n\n\n\n<p>Save the Excel file to a directory, for example, in my case, I use this Windows path: <strong>C:\\data\\employees.xlsx<\/strong><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"780\" height=\"540\" src=\"https:\/\/expert-only.com\/wp-content\/uploads\/2023\/02\/python-export-sq-server-table-into-excel.jpg\" alt=\"Excel file to import into a SQL Server table using a Python script\" class=\"wp-image-22605\" srcset=\"https:\/\/expert-only.com\/wp-content\/uploads\/2023\/02\/python-export-sq-server-table-into-excel.jpg 780w, https:\/\/expert-only.com\/wp-content\/uploads\/2023\/02\/python-export-sq-server-table-into-excel-300x208.jpg 300w, https:\/\/expert-only.com\/wp-content\/uploads\/2023\/02\/python-export-sq-server-table-into-excel-768x532.jpg 768w\" sizes=\"auto, (max-width: 780px) 100vw, 780px\" \/><figcaption class=\"wp-element-caption\"><strong><em>Excel file to import into a SQL Server table using a Python script<\/em><\/strong><\/figcaption><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"2-create-a-sql-server-table-to-store-the-excel-data\"><\/span>2. Create a SQL Server table to store the Excel data<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Before importing the data from the Excel file, we need to create a table in SQL Server to store the data. We will create a simple table named <code>employees<\/code> with four columns:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>id<\/li>\n\n\n\n<li>name<\/li>\n\n\n\n<li>department<\/li>\n\n\n\n<li>salary<\/li>\n<\/ul>\n\n\n\n<p>Use SQL Server Management Studio (SSMS) or execute the SQL query using the <a href=\"https:\/\/pypi.org\/project\/pyodbc\/\" target=\"_blank\" rel=\"noreferrer noopener\">pyodbc library<\/a> in Python to create the table in your SQL Server database.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"mssql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">CREATE TABLE dbo.employees (\n   id INT PRIMARY KEY,\n   name VARCHAR(50),\n   department VARCHAR(50),\n   salary INT\n);\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"3-python-script-to-import-data-from-excel-into-sql-server\"><\/span>3. Python script to import data from Excel into SQL Server<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Now, we will use the <strong><em>openpyxl<\/em><\/strong> library to read data from the Excel file and the <strong><em>pyodbc<\/em><\/strong> library to insert the data into the SQL Server table. The following Python code example demonstrates how easy it is to read data from the <em>employees.xlsx<\/em> file and insert it into the employees table. Of course you need to adjust the code in case of specific constraints.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Expert-Only.com\nimport openpyxl\nimport pyodbc\n\n# Load the Excel workbook and select the active worksheet\nworkbook = openpyxl.load_workbook(\"C:\\\\data\\\\employees.xlsx\")\nworksheet = workbook.active\n\n# Connect to the SQL Server database\nconnection = pyodbc.connect('Driver={SQL Server};'\n                            'Server=localhost;'\n                            'Database=Expert-Only;'\n                            'Trusted_Connection=yes;')\n\ncursor = connection.cursor()\n\n# Read data from the Excel file and insert it into the SQL Server table\nfor row in range(2, worksheet.max_row + 1):\n    id = worksheet.cell(row=row, column=1).value\n    name = worksheet.cell(row=row, column=2).value\n    department = worksheet.cell(row=row, column=3).value\n    salary = worksheet.cell(row=row, column=4).value\n\n    cursor.execute(\"INSERT INTO dbo.employees (id, name, department, salary) VALUES (?, ?, ?, ?)\",\n                   id, name, department, salary)\n\n# Commit the changes and close the connection\nconnection.commit()\nconnection.close()\n<\/pre>\n\n\n\n<p><strong>To import the Excel document into the SQL Server table, in the code above, we perform 5 main operations: <\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>We first load the Excel workbook and then select the active worksheet.<\/li>\n\n\n\n<li>Then, we connect to the SQL Server database using the <em>pyodbc<\/em> library.<\/li>\n\n\n\n<li>We loop through the rows in the Excel worksheet, starting from row 2 to ignore the header row.<\/li>\n\n\n\n<li>And we read the data from each cell in the row.<\/li>\n\n\n\n<li>Finally, we insert the data into the employees table using an <strong><a href=\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-insert-into-from-a-select\/\">INSERT INTO SQL Server query<\/a><\/strong> and commit the changes to the database.<\/li>\n<\/ol>\n\n\n\n<p>After executing the script, check the data from the Excel file successfully imported into the SQL Server table.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"720\" height=\"380\" src=\"https:\/\/expert-only.com\/wp-content\/uploads\/2023\/03\/python-import-excel-data-to-sql-server-table-ssms.jpg\" alt=\"Select data imported from the Excel file into the SQL Server table with SSMS\" class=\"wp-image-23509\" srcset=\"https:\/\/expert-only.com\/wp-content\/uploads\/2023\/03\/python-import-excel-data-to-sql-server-table-ssms.jpg 720w, https:\/\/expert-only.com\/wp-content\/uploads\/2023\/03\/python-import-excel-data-to-sql-server-table-ssms-300x158.jpg 300w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><figcaption class=\"wp-element-caption\"><em>Select data imported from the Excel file into the SQL Server table with SSMS<\/em><\/figcaption><\/figure><\/div>\n\n\n<h3 class=\"wp-block-heading\">About importing Excel data into SQL Server with Python<\/h3>\n\n\n\n<p>You have successfully learned how to import data from an Excel file into a SQL Server table using a Python script. By following the different steps outlined in this coding tutorial, you can now read data from an Excel file and insert it into a SQL Server table with proper formatting using Python. This skill can be useful for a wide range of data analysis, reporting tasks, and data migration projects. Continue to explore and practice with these libraries and tools to enhance your Python data manipulation skills.<\/p>\n\n\n\n<p>To go further, consider the following additional resources. Explore the <a href=\"https:\/\/pandas.pydata.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">Pandas library<\/a> for more sophisticated data manipulation and analysis tasks in Python. Learn how to manage Excel files with advanced formatting using the <a href=\"https:\/\/openpyxl.readthedocs.io\/en\/stable\/\" target=\"_blank\" rel=\"noreferrer noopener\">openpyxl<\/a> library. Indeed, by combining the knowledge from these resources, you can create more advanced data processing workflows, automate data import and export tasks, and develop custom solutions for your data management needs using Python and SQL Server.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">From our Python tutorials on importing data to SQL Server database<\/h5>\n\n\n\n<ol class=\"wp-block-list\">\n<li><a href=\"https:\/\/expert-only.com\/en\/python\/export-sql-server-table-to-excel-python\/\">Exporting a SQL Server table to an Excel file with Python<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/expert-only.com\/en\/python\/python-import-csv-data-to-sql-server\/\">How to import data from CSV to SQL Server in Python ?<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/expert-only.com\/en\/python\/import-xml-document-in-sql-server-python\/\">Tutorial on importing XML documents into SQL Server using Python<\/a><\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-embed aligncenter is-type-wp-embed is-provider-sql-and-it-tutorials wp-block-embed-sql-and-it-tutorials\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"4fYgn4EzSn\"><a href=\"https:\/\/expert-only.com\/en\/python\/zip-and-unzip-files-in-python\/\">How to zip and unzip files with the Python zipfile  module ?<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;How to zip and unzip files with the Python zipfile  module ?&#8221; &#8212; SQL and IT Tutorials\" src=\"https:\/\/expert-only.com\/en\/python\/zip-and-unzip-files-in-python\/embed\/#?secret=Zq5McLulSK#?secret=4fYgn4EzSn\" data-secret=\"4fYgn4EzSn\" width=\"500\" height=\"282\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><\/figure>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>A step-by-step tutorial on importing data from Excel documents into SQL Server databases using few lines of powerful Python scripts. In this tutorial, we will learn how to import data from an Excel file into a SQL Server table <a class=\"mh-excerpt-more\" href=\"https:\/\/expert-only.com\/en\/python\/how-to-import-an-excel-file-into-sql-server-using-python\/\" title=\"How To Import An Excel File Into SQL Server Using Python?\">&#8230;<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":10502,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[657],"tags":[],"class_list":{"0":"post-23497","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-python"},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.7 (Yoast SEO v26.2) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How To Import An Excel File Into SQL Server Using Python?<\/title>\n<meta name=\"description\" content=\"Learn how to import data from an Excel file into a SQL Server table using Python code and T-SQL scripts in five operations.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/expert-only.com\/en\/python\/how-to-import-an-excel-file-into-sql-server-using-python\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How To Import An Excel File Into SQL Server Using Python?\" \/>\n<meta property=\"og:description\" content=\"Learn how to import data from an Excel file into a SQL Server table using Python code and T-SQL scripts in five operations.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/expert-only.com\/en\/python\/how-to-import-an-excel-file-into-sql-server-using-python\/\" \/>\n<meta property=\"og:site_name\" content=\"SQL and IT Tutorials\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/ExpertOnlyCom\/\" \/>\n<meta property=\"article:published_time\" content=\"2024-01-01T05:41:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-02-23T10:31:10+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/code-1839406_1920x1080.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"1080\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Expert-Only\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@expert_only\" \/>\n<meta name=\"twitter:site\" content=\"@expert_only\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Expert-Only\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/expert-only.com\/en\/python\/how-to-import-an-excel-file-into-sql-server-using-python\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/expert-only.com\/en\/python\/how-to-import-an-excel-file-into-sql-server-using-python\/\"},\"author\":{\"name\":\"Expert-Only\",\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef\"},\"headline\":\"How To Import An Excel File Into SQL Server Using Python?\",\"datePublished\":\"2024-01-01T05:41:00+00:00\",\"dateModified\":\"2024-02-23T10:31:10+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/expert-only.com\/en\/python\/how-to-import-an-excel-file-into-sql-server-using-python\/\"},\"wordCount\":765,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/expert-only.com\/en\/#organization\"},\"image\":{\"@id\":\"https:\/\/expert-only.com\/en\/python\/how-to-import-an-excel-file-into-sql-server-using-python\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/code-1839406_1920x1080.jpg\",\"articleSection\":[\"Python tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/expert-only.com\/en\/python\/how-to-import-an-excel-file-into-sql-server-using-python\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/expert-only.com\/en\/python\/how-to-import-an-excel-file-into-sql-server-using-python\/\",\"url\":\"https:\/\/expert-only.com\/en\/python\/how-to-import-an-excel-file-into-sql-server-using-python\/\",\"name\":\"How To Import An Excel File Into SQL Server Using Python?\",\"isPartOf\":{\"@id\":\"https:\/\/expert-only.com\/en\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/expert-only.com\/en\/python\/how-to-import-an-excel-file-into-sql-server-using-python\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/expert-only.com\/en\/python\/how-to-import-an-excel-file-into-sql-server-using-python\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/code-1839406_1920x1080.jpg\",\"datePublished\":\"2024-01-01T05:41:00+00:00\",\"dateModified\":\"2024-02-23T10:31:10+00:00\",\"description\":\"Learn how to import data from an Excel file into a SQL Server table using Python code and T-SQL scripts in five operations.\",\"breadcrumb\":{\"@id\":\"https:\/\/expert-only.com\/en\/python\/how-to-import-an-excel-file-into-sql-server-using-python\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/expert-only.com\/en\/python\/how-to-import-an-excel-file-into-sql-server-using-python\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/expert-only.com\/en\/python\/how-to-import-an-excel-file-into-sql-server-using-python\/#primaryimage\",\"url\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/code-1839406_1920x1080.jpg\",\"contentUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/code-1839406_1920x1080.jpg\",\"width\":1920,\"height\":1080},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/expert-only.com\/en\/python\/how-to-import-an-excel-file-into-sql-server-using-python\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"en\",\"item\":\"https:\/\/expert-only.com\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How To Import An Excel File Into SQL Server Using Python?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/expert-only.com\/en\/#website\",\"url\":\"https:\/\/expert-only.com\/en\/\",\"name\":\"SQL and IT Tutorials\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/expert-only.com\/en\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/expert-only.com\/en\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/expert-only.com\/en\/#organization\",\"name\":\"Expert-Only\",\"url\":\"https:\/\/expert-only.com\/en\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/09\/cropped-logo_Expert-Only.jpg\",\"contentUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/09\/cropped-logo_Expert-Only.jpg\",\"width\":381,\"height\":174,\"caption\":\"Expert-Only\"},\"image\":{\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/ExpertOnlyCom\/\",\"https:\/\/x.com\/expert_only\",\"https:\/\/www.youtube.com\/channel\/UCMS5sR_FwAetB0FmciNvUaA\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef\",\"name\":\"Expert-Only\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/084b15660763ff5b13bb60b2f52f97bb?s=96&d=identicon&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/084b15660763ff5b13bb60b2f52f97bb?s=96&d=identicon&r=g\",\"caption\":\"Expert-Only\"}}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How To Import An Excel File Into SQL Server Using Python?","description":"Learn how to import data from an Excel file into a SQL Server table using Python code and T-SQL scripts in five operations.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/expert-only.com\/en\/python\/how-to-import-an-excel-file-into-sql-server-using-python\/","og_locale":"en_US","og_type":"article","og_title":"How To Import An Excel File Into SQL Server Using Python?","og_description":"Learn how to import data from an Excel file into a SQL Server table using Python code and T-SQL scripts in five operations.","og_url":"https:\/\/expert-only.com\/en\/python\/how-to-import-an-excel-file-into-sql-server-using-python\/","og_site_name":"SQL and IT Tutorials","article_publisher":"https:\/\/www.facebook.com\/ExpertOnlyCom\/","article_published_time":"2024-01-01T05:41:00+00:00","article_modified_time":"2024-02-23T10:31:10+00:00","og_image":[{"width":1920,"height":1080,"url":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/code-1839406_1920x1080.jpg","type":"image\/jpeg"}],"author":"Expert-Only","twitter_card":"summary_large_image","twitter_creator":"@expert_only","twitter_site":"@expert_only","twitter_misc":{"Written by":"Expert-Only","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/expert-only.com\/en\/python\/how-to-import-an-excel-file-into-sql-server-using-python\/#article","isPartOf":{"@id":"https:\/\/expert-only.com\/en\/python\/how-to-import-an-excel-file-into-sql-server-using-python\/"},"author":{"name":"Expert-Only","@id":"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef"},"headline":"How To Import An Excel File Into SQL Server Using Python?","datePublished":"2024-01-01T05:41:00+00:00","dateModified":"2024-02-23T10:31:10+00:00","mainEntityOfPage":{"@id":"https:\/\/expert-only.com\/en\/python\/how-to-import-an-excel-file-into-sql-server-using-python\/"},"wordCount":765,"commentCount":0,"publisher":{"@id":"https:\/\/expert-only.com\/en\/#organization"},"image":{"@id":"https:\/\/expert-only.com\/en\/python\/how-to-import-an-excel-file-into-sql-server-using-python\/#primaryimage"},"thumbnailUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/code-1839406_1920x1080.jpg","articleSection":["Python tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/expert-only.com\/en\/python\/how-to-import-an-excel-file-into-sql-server-using-python\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/expert-only.com\/en\/python\/how-to-import-an-excel-file-into-sql-server-using-python\/","url":"https:\/\/expert-only.com\/en\/python\/how-to-import-an-excel-file-into-sql-server-using-python\/","name":"How To Import An Excel File Into SQL Server Using Python?","isPartOf":{"@id":"https:\/\/expert-only.com\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/expert-only.com\/en\/python\/how-to-import-an-excel-file-into-sql-server-using-python\/#primaryimage"},"image":{"@id":"https:\/\/expert-only.com\/en\/python\/how-to-import-an-excel-file-into-sql-server-using-python\/#primaryimage"},"thumbnailUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/code-1839406_1920x1080.jpg","datePublished":"2024-01-01T05:41:00+00:00","dateModified":"2024-02-23T10:31:10+00:00","description":"Learn how to import data from an Excel file into a SQL Server table using Python code and T-SQL scripts in five operations.","breadcrumb":{"@id":"https:\/\/expert-only.com\/en\/python\/how-to-import-an-excel-file-into-sql-server-using-python\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/expert-only.com\/en\/python\/how-to-import-an-excel-file-into-sql-server-using-python\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/expert-only.com\/en\/python\/how-to-import-an-excel-file-into-sql-server-using-python\/#primaryimage","url":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/code-1839406_1920x1080.jpg","contentUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/code-1839406_1920x1080.jpg","width":1920,"height":1080},{"@type":"BreadcrumbList","@id":"https:\/\/expert-only.com\/en\/python\/how-to-import-an-excel-file-into-sql-server-using-python\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"en","item":"https:\/\/expert-only.com\/en\/"},{"@type":"ListItem","position":2,"name":"How To Import An Excel File Into SQL Server Using Python?"}]},{"@type":"WebSite","@id":"https:\/\/expert-only.com\/en\/#website","url":"https:\/\/expert-only.com\/en\/","name":"SQL and IT Tutorials","description":"","publisher":{"@id":"https:\/\/expert-only.com\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/expert-only.com\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/expert-only.com\/en\/#organization","name":"Expert-Only","url":"https:\/\/expert-only.com\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/expert-only.com\/en\/#\/schema\/logo\/image\/","url":"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/09\/cropped-logo_Expert-Only.jpg","contentUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/09\/cropped-logo_Expert-Only.jpg","width":381,"height":174,"caption":"Expert-Only"},"image":{"@id":"https:\/\/expert-only.com\/en\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/ExpertOnlyCom\/","https:\/\/x.com\/expert_only","https:\/\/www.youtube.com\/channel\/UCMS5sR_FwAetB0FmciNvUaA"]},{"@type":"Person","@id":"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef","name":"Expert-Only","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/expert-only.com\/en\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/084b15660763ff5b13bb60b2f52f97bb?s=96&d=identicon&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/084b15660763ff5b13bb60b2f52f97bb?s=96&d=identicon&r=g","caption":"Expert-Only"}}]}},"_links":{"self":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts\/23497","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/comments?post=23497"}],"version-history":[{"count":2,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts\/23497\/revisions"}],"predecessor-version":[{"id":30005,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts\/23497\/revisions\/30005"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/media\/10502"}],"wp:attachment":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/media?parent=23497"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/categories?post=23497"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/tags?post=23497"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}