{"id":25036,"date":"2023-04-03T05:36:00","date_gmt":"2023-04-03T03:36:00","guid":{"rendered":"https:\/\/expert-only.com\/?p=25036"},"modified":"2023-05-17T12:11:43","modified_gmt":"2023-05-17T10:11:43","slug":"export-sql-server-data-to-xml-with-ssis","status":"publish","type":"post","link":"https:\/\/expert-only.com\/en\/ssis\/export-sql-server-data-to-xml-with-ssis\/","title":{"rendered":"Export SQL Server data into an XML file with SSIS"},"content":{"rendered":"\n<h4 class=\"wp-block-heading has-text-align-center\" id=\"h-export-data-from-a-sql-server-table-into-an-xml-document-with-an-ssis-package\"><strong><em>Export data from a SQL Server table into an XML document with an SSIS package.<\/em><\/strong><\/h4>\n\n\n\n<p>To export a SQL Server table to an XML file type with an SSIS package and without any additional components, you need to transform the SQL data to XML using a query. SSIS does not provide a native XML component, only an XML source exists. Other software editors offer components for exporting to XML, such as the SSIS productivity pack from KingswaySoft, for example.<\/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\/ssis\/export-sql-server-data-to-xml-with-ssis\/#1-create-the-sql-server-table-with-data-to-export-in-xml\" >1. Create the SQL Server table with data to export in XML<\/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\/ssis\/export-sql-server-data-to-xml-with-ssis\/#2-build-the-query-to-transform-sql-data-into-xml\" >2. Build the query to transform SQL data into XML<\/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\/ssis\/export-sql-server-data-to-xml-with-ssis\/#3-configure-the-ssis-flow-from-the-sql-source-table-to-the-xml-file\" >3. Configure the SSIS flow from the SQL source table to the XML file<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/expert-only.com\/en\/ssis\/export-sql-server-data-to-xml-with-ssis\/#4-configure-the-xml-file-to-be-exported-from-ssis\" >4. Configure the XML file to be exported from SSIS<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/expert-only.com\/en\/ssis\/export-sql-server-data-to-xml-with-ssis\/#5-run-the-package-to-export-the-table-to-xml-and-check-the-content\" >5. Run the package to export the table to XML and check the content<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\" id=\"h-1-create-the-sql-server-table-with-data-to-export-in-xml\"><span class=\"ez-toc-section\" id=\"1-create-the-sql-server-table-with-data-to-export-in-xml\"><\/span>1. Create the SQL Server table with data to export in XML<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The first step of course is to create a sample source table in SSMS to have some data. Use the following code to create the customer table and insert 8 rows to export in XML format.<\/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=\"\">-- Cr\u00e9er la table des clients\nCREATE TABLE [dbo].[Customers](\n   [CustomerID] [int] NOT NULL,\n   [FirstName] [nvarchar](20) NULL,\n   [LastName] [nvarchar](20) NULL,\n   [City] [nvarchar](20) NULL,\n   [Country] [nvarchar](50) NULL,\n   CONSTRAINT [CustomersPrimaryKeyCustomerID] PRIMARY KEY CLUSTERED ([CustomerID] ASC)\n);\nGO\n\n-- Ins\u00e9rer 8 lignes \u00e0 exporter au format XML\nINSERT INTO [dbo].[Customers] VALUES (1, N'Ali', N'Ahmed', N'Cairo', N'Egypt');\nINSERT INTO [dbo].[Customers] VALUES (2, N'Johnny', N'John', N'Toronto', N'Canada');\nINSERT INTO [dbo].[Customers] VALUES (3, N'John', N'Doe', N'Mexico City', N'Mexico');\nINSERT INTO [dbo].[Customers] VALUES (4, N'Shu', N'Abbas', N'Paris', N'France');\nINSERT INTO [dbo].[Customers] VALUES (5, N'Jeane', N'Raffin', N'Liushutun', N'China');\nINSERT INTO [dbo].[Customers] VALUES (6, N'Legra', N'Leate', N'B\u0142aszki', N'Poland');\nINSERT INTO [dbo].[Customers] VALUES (7, N'Sullivan', N'Goadby', N'Xiaoguwei', N'China');\nINSERT INTO [dbo].[Customers] VALUES (8, N'Tom', N'Ellams', N'Lop Buri', N'Thailand');<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"2-build-the-query-to-transform-sql-data-into-xml\"><\/span>2. Build the query to transform SQL data into XML<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>After creating the table and inserting customer data, build the SQL Server query to transform SQL data into XML.<\/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=\"\">-- SQL Select query to check the Customers data\nSELECT\n   [CustomerID],\n   [FirstName],\n   [LastName],\n   [City],\n   [Country]\nFROM [dbo].[Customers];\n<\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/10\/ssis-export-table-to-xml-1-check-source-data-ssms.jpg\" alt=\"Use SSMS to check and export SQL Server data into an XML file with SSIS\" class=\"wp-image-12870\" width=\"600\" height=\"540\" srcset=\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/10\/ssis-export-table-to-xml-1-check-source-data-ssms.jpg 600w, https:\/\/expert-only.com\/wp-content\/uploads\/2022\/10\/ssis-export-table-to-xml-1-check-source-data-ssms-300x270.jpg 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><figcaption class=\"wp-element-caption\"><em>Use SSMS to check and export SQL Server data into an XML file with SSIS<\/em><\/figcaption><\/figure><\/div>\n\n\n<p>Now, here is the query with the XML functions to create the XML elements Customers and Customer.<\/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=\"\">-- XML Query to transform the data into XML format and allow the export\nSELECT \n   [CustomerID],\n   [FirstName],\n   [LastName],\n   [City],\n   [Country]   \nFROM [dbo].[Customers]\nFOR XML PATH('Customer'),\n      ROOT('Customers'),\n         ELEMENTS XSINIL;<\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"460\" src=\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/10\/ssis-export-table-to-xml-2-build-xml-query.jpg\" alt=\"Edit and run the XML SQL query to transform the rows into XML format\" class=\"wp-image-12876\" srcset=\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/10\/ssis-export-table-to-xml-2-build-xml-query.jpg 600w, https:\/\/expert-only.com\/wp-content\/uploads\/2022\/10\/ssis-export-table-to-xml-2-build-xml-query-300x230.jpg 300w, https:\/\/expert-only.com\/wp-content\/uploads\/2022\/10\/ssis-export-table-to-xml-2-build-xml-query-80x60.jpg 80w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><figcaption class=\"wp-element-caption\"><em>Edit and run the XML SQL query to transform the rows into XML format<\/em><\/figcaption><\/figure><\/div>\n\n\n<p>Click on the link in the result to display the XML file in a new SSMS window.<\/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\/2022\/10\/ssis-export-table-to-xml-3-raw-xml-result.jpg\" alt=\"Customer table in XML format displayed in the SSMS tab\" class=\"wp-image-12881\" srcset=\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/10\/ssis-export-table-to-xml-3-raw-xml-result.jpg 720w, https:\/\/expert-only.com\/wp-content\/uploads\/2022\/10\/ssis-export-table-to-xml-3-raw-xml-result-300x158.jpg 300w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><figcaption class=\"wp-element-caption\"><em>Customer table in XML format displayed in the SSMS tab<\/em><\/figcaption><\/figure><\/div>\n\n\n<p>The data returned by the XML query is of IMAGE type, meaning it is a file. To transform the SQL Server IMAGE type into text, include the query as a subquery. The column is also renamed to <em>XML_Column<\/em> <a href=\"https:\/\/expert-only.com\/en\/ssis\/create-a-simple-ssis-data-flow\/\">to facilitate mapping from the SSIS data flow<\/a>. Use a subquery to encapsulate the previous one and display the result as text in a SQL column.<\/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=\"\">SELECT (\n   SELECT \n       [CustomerID],\n       [FirstName],\n       [LastName],\n       [City],\n       [Country]   \n   FROM [dbo].[Customers]\n   FOR XML PATH('Customer'),\n         ROOT('Customers'),\n            ELEMENTS XSINIL\n) AS XML_Column;\n<\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"680\" height=\"440\" src=\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/10\/ssis-export-table-to-xml-4-xml-to-column-ssms.jpg\" alt=\"XML query in a subquery executed in SSMS to display the result as text\" class=\"wp-image-12888\" srcset=\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/10\/ssis-export-table-to-xml-4-xml-to-column-ssms.jpg 680w, https:\/\/expert-only.com\/wp-content\/uploads\/2022\/10\/ssis-export-table-to-xml-4-xml-to-column-ssms-300x194.jpg 300w, https:\/\/expert-only.com\/wp-content\/uploads\/2022\/10\/ssis-export-table-to-xml-4-xml-to-column-ssms-678x440.jpg 678w\" sizes=\"auto, (max-width: 680px) 100vw, 680px\" \/><figcaption class=\"wp-element-caption\"><em>XML query in a subquery executed in SSMS to display the result as text<\/em><\/figcaption><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"3-configure-the-ssis-flow-from-the-sql-source-table-to-the-xml-file\"><\/span>3. Configure the SSIS flow from the SQL source table to the XML file<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Add the SSIS OLE DB Source and the Flat File Destination components in the data flow.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"660\" height=\"580\" src=\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/10\/ssis-export-table-to-xml-5-add-ole-db-and-flat-file.jpg\" alt=\"SSIS data flow to export SQL Server data into an XML file with SSIS\" class=\"wp-image-12898\" srcset=\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/10\/ssis-export-table-to-xml-5-add-ole-db-and-flat-file.jpg 660w, https:\/\/expert-only.com\/wp-content\/uploads\/2022\/10\/ssis-export-table-to-xml-5-add-ole-db-and-flat-file-300x264.jpg 300w\" sizes=\"auto, (max-width: 660px) 100vw, 660px\" \/><figcaption class=\"wp-element-caption\"><em>SSIS data flow to export SQL Server data into an XML file with SSIS<\/em><\/figcaption><\/figure><\/div>\n\n\n<p>Open the OLE DB Source component and <a href=\"https:\/\/expert-only.com\/en\/ssis\/how-to-connect-to-sql-server-with-ssis\/\">use a connection to the source database<\/a>. Enter the query from the previous step using a simple copy \/ paste in the SSIS OLE DB Source Editor.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/10\/ssis-export-table-to-xml-6-add-sql-query-ole-db.jpg\" alt=\"Insert the source query to return the column in XML format\" class=\"wp-image-12903\" width=\"660\" height=\"680\" srcset=\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/10\/ssis-export-table-to-xml-6-add-sql-query-ole-db.jpg 660w, https:\/\/expert-only.com\/wp-content\/uploads\/2022\/10\/ssis-export-table-to-xml-6-add-sql-query-ole-db-291x300.jpg 291w\" sizes=\"auto, (max-width: 660px) 100vw, 660px\" \/><figcaption class=\"wp-element-caption\"><em>Insert the source query to return the column in XML format<\/em><\/figcaption><\/figure><\/div>\n\n\n<p>If you change the query, <strong>check that the data type is DT_NTEXT<\/strong>, i.e. in Unicode Text format, to avoid errors when mapping to the file. To do so, right-click and choose <em>Show Advanced Edito<\/em>r.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"816\" height=\"879\" src=\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/10\/ssis-export-table-to-xml-7-advanced-editor-xml-column-dt_ntext.jpg\" alt=\"Check the format of the XML column to export as a document\" class=\"wp-image-12910\" srcset=\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/10\/ssis-export-table-to-xml-7-advanced-editor-xml-column-dt_ntext.jpg 816w, https:\/\/expert-only.com\/wp-content\/uploads\/2022\/10\/ssis-export-table-to-xml-7-advanced-editor-xml-column-dt_ntext-278x300.jpg 278w, https:\/\/expert-only.com\/wp-content\/uploads\/2022\/10\/ssis-export-table-to-xml-7-advanced-editor-xml-column-dt_ntext-768x827.jpg 768w\" sizes=\"auto, (max-width: 816px) 100vw, 816px\" \/><figcaption class=\"wp-element-caption\"><em>Check the format of the XML column to export as a document<\/em><\/figcaption><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"4-configure-the-xml-file-to-be-exported-from-ssis\"><\/span>4. Configure the XML file to be exported from SSIS<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>From the file component, open the <em>Flat File Destination Editor<\/em> Window and create a new flat file connection. Choose the <strong><em>Delimited<\/em><\/strong> type.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"820\" height=\"780\" src=\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/10\/ssis-export-table-to-xml-8-new-flat-file.jpg\" alt=\"Create a new flat file connection to export the XML file\" class=\"wp-image-12919\" srcset=\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/10\/ssis-export-table-to-xml-8-new-flat-file.jpg 820w, https:\/\/expert-only.com\/wp-content\/uploads\/2022\/10\/ssis-export-table-to-xml-8-new-flat-file-300x285.jpg 300w, https:\/\/expert-only.com\/wp-content\/uploads\/2022\/10\/ssis-export-table-to-xml-8-new-flat-file-768x731.jpg 768w\" sizes=\"auto, (max-width: 820px) 100vw, 820px\" \/><figcaption class=\"wp-element-caption\"><em>Create a new flat file connection to export the XML file<\/em><\/figcaption><\/figure><\/div>\n\n\n<p>To set up the file, follow these steps:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Rename the XML file: <strong>XML File Export<\/strong><\/li>\n\n\n\n<li>Choose the path on the disk, in our case it is: <strong>C:\\data\\Customers_Data_Export.xml<\/strong><\/li>\n\n\n\n<li>Select <strong>Unicode<\/strong> to ensure the mapping with the source column.<\/li>\n<\/ol>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"729\" height=\"714\" src=\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/10\/ssis-export-table-to-xml-9-set-up-xml-file.jpg\" alt=\"Configure the options for the target XML file to be exported\" class=\"wp-image-12928\" srcset=\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/10\/ssis-export-table-to-xml-9-set-up-xml-file.jpg 729w, https:\/\/expert-only.com\/wp-content\/uploads\/2022\/10\/ssis-export-table-to-xml-9-set-up-xml-file-300x294.jpg 300w\" sizes=\"auto, (max-width: 729px) 100vw, 729px\" \/><figcaption class=\"wp-element-caption\"><em>Configure the options for the target XML file to be exported<\/em><\/figcaption><\/figure><\/div>\n\n\n<p>By default, Integration Services uses the <em>DT_WSTR type with a length of 255 characters<\/em>. Now set the XML column to adapt it to the column we export. <\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>From the <strong>Advanced<\/strong> tab<\/li>\n\n\n\n<li>Rename the column with the same name as the source: <strong>XML_Column<\/strong><\/li>\n\n\n\n<li>Change the data type to Unicode text: <strong>Unicode text stream [DT_NTEXT]<\/strong><\/li>\n<\/ol>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"775\" height=\"745\" src=\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/10\/ssis-export-table-to-xml-10-change-xml-column-dt_ntext.jpg\" alt=\"Rename the column and change the type to Unicode text stream DT_NTEXT\" class=\"wp-image-12938\" srcset=\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/10\/ssis-export-table-to-xml-10-change-xml-column-dt_ntext.jpg 775w, https:\/\/expert-only.com\/wp-content\/uploads\/2022\/10\/ssis-export-table-to-xml-10-change-xml-column-dt_ntext-300x288.jpg 300w, https:\/\/expert-only.com\/wp-content\/uploads\/2022\/10\/ssis-export-table-to-xml-10-change-xml-column-dt_ntext-768x738.jpg 768w\" sizes=\"auto, (max-width: 775px) 100vw, 775px\" \/><figcaption class=\"wp-element-caption\"><em>Rename the column and change the type to Unicode text stream DT_NTEXT<\/em><\/figcaption><\/figure><\/div>\n\n\n<p>Also check the mapping of the column from the <em>Mappings<\/em> tab.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"440\" src=\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/10\/ssis-export-table-to-xml-11-check-xml-file-mapping.jpg\" alt=\"Mapping from the SQL Server source table to the XML file to export with SSIS\" class=\"wp-image-12945\" srcset=\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/10\/ssis-export-table-to-xml-11-check-xml-file-mapping.jpg 600w, https:\/\/expert-only.com\/wp-content\/uploads\/2022\/10\/ssis-export-table-to-xml-11-check-xml-file-mapping-300x220.jpg 300w, https:\/\/expert-only.com\/wp-content\/uploads\/2022\/10\/ssis-export-table-to-xml-11-check-xml-file-mapping-80x60.jpg 80w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><figcaption class=\"wp-element-caption\"><em>Mapping from the SQL Server source table to the XML file to export with SSIS<\/em><\/figcaption><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"5-run-the-package-to-export-the-table-to-xml-and-check-the-content\"><\/span>5. Run the package to export the table to XML and check the content<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Finally, run the package to actually export the data from the SQL Server source table into the XML document, i.e. a file with the XML format. Only one row is transferred because the column contains the entire file in XML format and not the classic rows in SQL format.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/10\/ssis-export-table-to-xml-12-execute-xml-file-export.jpg\" alt=\"Run the SSIS package and Export SQL Server data into an XML file with Visual Studio\" class=\"wp-image-12952\" width=\"720\" height=\"580\" srcset=\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/10\/ssis-export-table-to-xml-12-execute-xml-file-export.jpg 720w, https:\/\/expert-only.com\/wp-content\/uploads\/2022\/10\/ssis-export-table-to-xml-12-execute-xml-file-export-300x242.jpg 300w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><figcaption class=\"wp-element-caption\"><em>Run the SSIS package and Export SQL Server data into an XML file with Visual Studio<\/em><\/figcaption><\/figure><\/div>\n\n\n<p>Then check the exported file, i.e. from <strong>C:\\data\\Customers_Data_Export.xml<\/strong>.<\/p>\n\n\n\n<p>Open the file with <a href=\"https:\/\/www.google.fr\/chrome\/\" target=\"_blank\" rel=\"noreferrer noopener\">Google Chrome<\/a> or another open source web browser like <a href=\"https:\/\/www.mozilla.org\/en-US\/firefox\/new\/\" target=\"_blank\" rel=\"noreferrer noopener\">Mozilla Firefox<\/a> for example. And finally check the data and the structure of the file.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"680\" height=\"540\" src=\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/10\/ssis-export-table-to-xml-13-check-xml-export-file-chrome.jpg\" alt=\"Open the XML file with Google Chrome to display the structure\" class=\"wp-image-12966\" srcset=\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/10\/ssis-export-table-to-xml-13-check-xml-export-file-chrome.jpg 680w, https:\/\/expert-only.com\/wp-content\/uploads\/2022\/10\/ssis-export-table-to-xml-13-check-xml-export-file-chrome-300x238.jpg 300w\" sizes=\"auto, (max-width: 680px) 100vw, 680px\" \/><figcaption class=\"wp-element-caption\"><em>Open the XML file with Google Chrome to display the structure<\/em><\/figcaption><\/figure><\/div>\n\n\n<h3 class=\"wp-block-heading\">Conclusion on exporting data into an XML document with SSIS<\/h3>\n\n\n\n<p>To conclude, the process to export SQL Server data into an XML file with SSIS is not completely guided, as SSIS does not provide a native component for XML export. However, with T-SQL code and available components, it is possible to adapt the query to the data structure and configure the components with the appropriate data type.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Useful resources on data export with SSIS or Python<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/expert-only.com\/en\/ssis\/export-sql-data-in-csv-with-ssis\/\"><strong>Export SQL Server data into a text file with SSIS<\/strong><\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/expert-only.com\/en\/ssis\/export-sql-server-data-to-excel\/\"><strong>SSIS package to export a SQL table to an Excel file<\/strong><\/a><\/li>\n\n\n\n<li><strong><a href=\"https:\/\/expert-only.com\/en\/python\/export-sql-server-data-to-csv-in-python\/\">Use Python to export SQL Server data into a CSV file<\/a><\/strong><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>Export data from a SQL Server table into an XML document with an SSIS package. To export a SQL Server table to an XML file type with an SSIS package and without any additional components, you need to transform <a class=\"mh-excerpt-more\" href=\"https:\/\/expert-only.com\/en\/ssis\/export-sql-server-data-to-xml-with-ssis\/\" title=\"Export SQL Server data into an XML file with SSIS\">&#8230;<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":10654,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[516],"tags":[],"class_list":{"0":"post-25036","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-ssis"},"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>Export SQL Server data into an XML file with SSIS - MS BI<\/title>\n<meta name=\"description\" content=\"Step by step tutorial to export SQL Server data from a table into an XML file using an SSIS package with the XML query to convert the data.\" \/>\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\/ssis\/export-sql-server-data-to-xml-with-ssis\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Export SQL Server data into an XML file with SSIS\" \/>\n<meta property=\"og:description\" content=\"Step by step tutorial to export SQL Server data from a table into an XML file using an SSIS package with the XML query to convert the data.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/expert-only.com\/en\/ssis\/export-sql-server-data-to-xml-with-ssis\/\" \/>\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=\"2023-04-03T03:36:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-05-17T10:11:43+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/fresh-glass-coffee-cup-2D256C64A99_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=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/expert-only.com\/en\/ssis\/export-sql-server-data-to-xml-with-ssis\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/expert-only.com\/en\/ssis\/export-sql-server-data-to-xml-with-ssis\/\"},\"author\":{\"name\":\"Expert-Only\",\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef\"},\"headline\":\"Export SQL Server data into an XML file with SSIS\",\"datePublished\":\"2023-04-03T03:36:00+00:00\",\"dateModified\":\"2023-05-17T10:11:43+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/expert-only.com\/en\/ssis\/export-sql-server-data-to-xml-with-ssis\/\"},\"wordCount\":879,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/expert-only.com\/en\/#organization\"},\"image\":{\"@id\":\"https:\/\/expert-only.com\/en\/ssis\/export-sql-server-data-to-xml-with-ssis\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/fresh-glass-coffee-cup-2D256C64A99_1920x1080.jpg\",\"articleSection\":[\"SSIS\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/expert-only.com\/en\/ssis\/export-sql-server-data-to-xml-with-ssis\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/expert-only.com\/en\/ssis\/export-sql-server-data-to-xml-with-ssis\/\",\"url\":\"https:\/\/expert-only.com\/en\/ssis\/export-sql-server-data-to-xml-with-ssis\/\",\"name\":\"Export SQL Server data into an XML file with SSIS - MS BI\",\"isPartOf\":{\"@id\":\"https:\/\/expert-only.com\/en\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/expert-only.com\/en\/ssis\/export-sql-server-data-to-xml-with-ssis\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/expert-only.com\/en\/ssis\/export-sql-server-data-to-xml-with-ssis\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/fresh-glass-coffee-cup-2D256C64A99_1920x1080.jpg\",\"datePublished\":\"2023-04-03T03:36:00+00:00\",\"dateModified\":\"2023-05-17T10:11:43+00:00\",\"description\":\"Step by step tutorial to export SQL Server data from a table into an XML file using an SSIS package with the XML query to convert the data.\",\"breadcrumb\":{\"@id\":\"https:\/\/expert-only.com\/en\/ssis\/export-sql-server-data-to-xml-with-ssis\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/expert-only.com\/en\/ssis\/export-sql-server-data-to-xml-with-ssis\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/expert-only.com\/en\/ssis\/export-sql-server-data-to-xml-with-ssis\/#primaryimage\",\"url\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/fresh-glass-coffee-cup-2D256C64A99_1920x1080.jpg\",\"contentUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/fresh-glass-coffee-cup-2D256C64A99_1920x1080.jpg\",\"width\":1920,\"height\":1080},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/expert-only.com\/en\/ssis\/export-sql-server-data-to-xml-with-ssis\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"en\",\"item\":\"https:\/\/expert-only.com\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Export SQL Server data into an XML file with SSIS\"}]},{\"@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":"Export SQL Server data into an XML file with SSIS - MS BI","description":"Step by step tutorial to export SQL Server data from a table into an XML file using an SSIS package with the XML query to convert the data.","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\/ssis\/export-sql-server-data-to-xml-with-ssis\/","og_locale":"en_US","og_type":"article","og_title":"Export SQL Server data into an XML file with SSIS","og_description":"Step by step tutorial to export SQL Server data from a table into an XML file using an SSIS package with the XML query to convert the data.","og_url":"https:\/\/expert-only.com\/en\/ssis\/export-sql-server-data-to-xml-with-ssis\/","og_site_name":"SQL and IT Tutorials","article_publisher":"https:\/\/www.facebook.com\/ExpertOnlyCom\/","article_published_time":"2023-04-03T03:36:00+00:00","article_modified_time":"2023-05-17T10:11:43+00:00","og_image":[{"width":1920,"height":1080,"url":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/fresh-glass-coffee-cup-2D256C64A99_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":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/expert-only.com\/en\/ssis\/export-sql-server-data-to-xml-with-ssis\/#article","isPartOf":{"@id":"https:\/\/expert-only.com\/en\/ssis\/export-sql-server-data-to-xml-with-ssis\/"},"author":{"name":"Expert-Only","@id":"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef"},"headline":"Export SQL Server data into an XML file with SSIS","datePublished":"2023-04-03T03:36:00+00:00","dateModified":"2023-05-17T10:11:43+00:00","mainEntityOfPage":{"@id":"https:\/\/expert-only.com\/en\/ssis\/export-sql-server-data-to-xml-with-ssis\/"},"wordCount":879,"commentCount":0,"publisher":{"@id":"https:\/\/expert-only.com\/en\/#organization"},"image":{"@id":"https:\/\/expert-only.com\/en\/ssis\/export-sql-server-data-to-xml-with-ssis\/#primaryimage"},"thumbnailUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/fresh-glass-coffee-cup-2D256C64A99_1920x1080.jpg","articleSection":["SSIS"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/expert-only.com\/en\/ssis\/export-sql-server-data-to-xml-with-ssis\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/expert-only.com\/en\/ssis\/export-sql-server-data-to-xml-with-ssis\/","url":"https:\/\/expert-only.com\/en\/ssis\/export-sql-server-data-to-xml-with-ssis\/","name":"Export SQL Server data into an XML file with SSIS - MS BI","isPartOf":{"@id":"https:\/\/expert-only.com\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/expert-only.com\/en\/ssis\/export-sql-server-data-to-xml-with-ssis\/#primaryimage"},"image":{"@id":"https:\/\/expert-only.com\/en\/ssis\/export-sql-server-data-to-xml-with-ssis\/#primaryimage"},"thumbnailUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/fresh-glass-coffee-cup-2D256C64A99_1920x1080.jpg","datePublished":"2023-04-03T03:36:00+00:00","dateModified":"2023-05-17T10:11:43+00:00","description":"Step by step tutorial to export SQL Server data from a table into an XML file using an SSIS package with the XML query to convert the data.","breadcrumb":{"@id":"https:\/\/expert-only.com\/en\/ssis\/export-sql-server-data-to-xml-with-ssis\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/expert-only.com\/en\/ssis\/export-sql-server-data-to-xml-with-ssis\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/expert-only.com\/en\/ssis\/export-sql-server-data-to-xml-with-ssis\/#primaryimage","url":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/fresh-glass-coffee-cup-2D256C64A99_1920x1080.jpg","contentUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/fresh-glass-coffee-cup-2D256C64A99_1920x1080.jpg","width":1920,"height":1080},{"@type":"BreadcrumbList","@id":"https:\/\/expert-only.com\/en\/ssis\/export-sql-server-data-to-xml-with-ssis\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"en","item":"https:\/\/expert-only.com\/en\/"},{"@type":"ListItem","position":2,"name":"Export SQL Server data into an XML file with SSIS"}]},{"@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\/25036","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=25036"}],"version-history":[{"count":0,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts\/25036\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/media\/10654"}],"wp:attachment":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/media?parent=25036"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/categories?post=25036"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/tags?post=25036"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}