{"id":6961,"date":"2019-05-30T15:37:37","date_gmt":"2019-05-30T15:37:37","guid":{"rendered":"https:\/\/zappysys.com\/blog\/?p=6961"},"modified":"2026-03-11T07:08:29","modified_gmt":"2026-03-11T07:08:29","slug":"import-amazon-mws-data-sql-server-t-sql","status":"publish","type":"post","link":"https:\/\/zappysys.com\/blog\/import-amazon-mws-data-sql-server-t-sql\/","title":{"rendered":"How to import Amazon MWS data into SQL Server (T-SQL)"},"content":{"rendered":"<h2>Introduction<\/h2>\n<div class=\"su-note\"  style=\"border-color:#e2dec9;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#fcf8e3;border-color:#ffffff;color:#8a6d3b;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<strong><span style=\"vertical-align: text-bottom;font-size: 0.86em;\">\u26a0\ufe0f<\/span> Deprecation Notice: MWS API is deprecated<\/strong><br \/>\nAmazon&#8217;s MWS (Marketplace Web Service) is being deprecated and <strong>replaced by the newer AWS Selling Partner API (SP-API).<\/strong> For a more robust and secure integration, we <strong>recommend<\/strong> using our <strong><a href=\"\/api\/integration-hub\/amazon-selling-partner-connector\/\">AWS Selling Partner (SP-API) Connector<\/a>.<\/strong> As Amazon is phasing out MWS functionality and eventually plans to fully deprecate it.<br \/>\n<\/div><\/div>\n<p><a href=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2016\/10\/amazon-mws-api-integration.png\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-1632 alignleft\" src=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2016\/10\/amazon-mws-api-integration.png\" alt=\"\" width=\"98\" height=\"98\" srcset=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2016\/10\/amazon-mws-api-integration.png 505w, https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2016\/10\/amazon-mws-api-integration-150x150.png 150w, https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2016\/10\/amazon-mws-api-integration-300x300.png 300w\" sizes=\"(max-width: 98px) 100vw, 98px\" \/><\/a>In our previous blog post we saw how to <a href=\"https:\/\/zappysys.com\/blog\/import-rest-api-json-sql-server\/\" target=\"_blank\" rel=\"noopener\">import rest API in SQL Server<\/a>. Using same concepts lets look at how to import Amazon MWS Data into SQL Server. We will explore many techniques to call Amazon MWS API and learn how to automate Amazon MWS data extraction without doing any ETL. We will call MWS XML or CSV API just using T-SQL code. We will also learn how to Download Reports from by calling MWS API.<\/p>\n<p>You can also refer other articles <a href=\"https:\/\/zappysys.com\/blog\/import-amazon-mws-data-power-bi\/\" target=\"_blank\" rel=\"noopener\">here (Power BI)<\/a> and <a href=\"https:\/\/zappysys.com\/blog\/call-amazon-mws-api-using-ssis-marketplace-web-service\/\" target=\"_blank\" rel=\"noopener\">here (SSIS)<\/a><\/p>\n<p>&nbsp;<\/p>\n<div class=\"content_block\" id=\"custom_post_widget-7048\"><h2>Requirements<\/h2>\r\nThis article talks about few tools and techniques in order to load API data in SQL Server. Please make sure following prerequisites are met.\r\n<ol>\r\n \t<li>Download and Install <a href=\"https:\/\/zappysys.com\/products\/odbc-powerpack\/\" target=\"_blank\" rel=\"noopener\">ZappySys ODBC PowerPack<\/a> (This includes XML \/ JSON \/ REST API and few other drivers for SQL Server and ODBC connectivity in tools like Excel, Power BI, SSRS)<\/li>\r\n \t<li>Make sure you have access to SQL Server Instance. If you cant find one still want to try what is mentioned in this article then install <a href=\"https:\/\/www.microsoft.com\/en-us\/sql-server\/sql-server-editions-express\" target=\"_blank\" rel=\"noopener\">FREE SQL Express Edition<\/a><\/li>\r\n \t<li>Confirm that you have SSMS Installed. If you don't have then you can download <a href=\"https:\/\/docs.microsoft.com\/en-us\/sql\/ssms\/download-sql-server-management-studio-ssms?view=sql-server-2017\">from here<\/a>.<\/li>\r\n<\/ol><\/div>\n<h2><\/h2>\n<h2>About Amazon MWS\u00a0 API<\/h2>\n<p>If you want to sell something on Amazon you can use their e-commerce platform with some monthly fee. You can setup your entire online store \/ inventory using admin interface.<\/p>\n<p>Amazon Marketplace Web Service (Amazon MWS) is an integrated web service API that helps Amazon sellers to programmatically exchange data on listings, orders, payments, reports, and more. Using these API you can read or write data from your Seller account and integrate it inside your own Systems (e.g. Reporting \/ ETL \/ BI tools).<\/p>\n<div class=\"su-note\"  style=\"border-color:#e5de9d;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#fff8b7;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">NOTE: Amazon MWS may allow only certain number of requests per minute depending which API you calling so you might want to use each call wisely. We will suggest you various techniques throughout this article so you can avoid errors so read each section carefully. You can find Throttling information on API help page itself (<a href=\"https:\/\/docs.developer.amazonservices.com\/en_IT\/orders-2013-09-01\/Orders_ListOrders.html\" target=\"_blank\" rel=\"noopener\">like this one<\/a>\u00a0see throttling section. Also <a href=\"https:\/\/docs.developer.amazonservices.com\/en_IT\/dev_guide\/DG_Throttling.html\">this one<\/a>).<\/div><\/div>\n<h2>Obtain MWS API Access Key \/ Secret and Seller ID<\/h2>\n<p>Very first thing to call any MWS API is to obtain Access Key, Secret Key and Seller ID (i.e. Merchant ID). To obtain this you first have to <a href=\"https:\/\/docs.developer.amazonservices.com\/en_US\/dev_guide\/DG_Registering.html\" target=\"_blank\" rel=\"noopener\">register a developer<\/a>.<\/p>\n<p>Here is where to look for your Merchant ID and Key \/ Secret.\u00a0 Here is direct link to <a href=\"https:\/\/sellercentral.amazon.com\/gp\/account-manager\/home.html\/ref=xx_userperms_dnav_userperms\" target=\"_blank\" rel=\"noopener\">User Permissions<\/a> page.<\/p>\n<div id=\"attachment_4843\" style=\"width: 997px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/09\/obtain-amazon-mws-developer-aws-access-key-secret-key-sellerid.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-4843\" class=\"size-full wp-image-4843\" src=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/09\/obtain-amazon-mws-developer-aws-access-key-secret-key-sellerid.png\" alt=\"How to get Amazon MWS developer keys and know your Merchant ID (i.e. Seller ID)\" width=\"987\" height=\"422\" srcset=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/09\/obtain-amazon-mws-developer-aws-access-key-secret-key-sellerid.png 987w, https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/09\/obtain-amazon-mws-developer-aws-access-key-secret-key-sellerid-300x128.png 300w, https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/09\/obtain-amazon-mws-developer-aws-access-key-secret-key-sellerid-768x328.png 768w\" sizes=\"(max-width: 987px) 100vw, 987px\" \/><\/a><p id=\"caption-attachment-4843\" class=\"wp-caption-text\">How to get Amazon MWS developer keys and know your Merchant ID (i.e. Seller ID)<\/p><\/div>\n<h2>Getting Started<\/h2>\n<p>Now let&#8217;s look at step by step instructions on how to call Amazon MWS API and then import into Power BI. In below steps we will use\u00a0\u00a0<a href=\"https:\/\/zappysys.com\/products\/odbc-powerpack\/\" target=\"_blank\" rel=\"noopener\">ZappySys ODBC PowerPack<\/a>\u00a0so make sure it&#8217;s installed first.<\/p>\n<h3>Using ScratchPad to Test\u00a0Amazon MWS API<\/h3>\n<p>Each MWS API has set of required and optional parameters. You can refer each API page for details. For example\u00a0<a href=\"https:\/\/docs.developer.amazonservices.com\/en_US\/products\/Products_ListMatchingProducts.html\" target=\"_blank\" rel=\"noopener\">ListMatchingProducts<\/a> API which we will use as an example. To make MWS API testing \/ learning easy, Amazon provides\u00a0online testing tool called <a href=\"https:\/\/mws.amazonservices.com\/scratchpad\/index.html\" target=\"_blank\" rel=\"noopener\">MWS ScratchPad<\/a>. We will use this tool to craft API requests and use that information in ODBC driver SQL queries and later import data in Power BI.<\/p>\n<ol>\n<li>Open\u00a0<a href=\"https:\/\/mws.amazonservices.com\/scratchpad\/index.html\" target=\"_blank\" rel=\"noopener\">MWS ScratchPad<\/a>\u00a0 by vising <strong>https:\/\/mws.amazonservices.com\/scratchpad\/index.html<\/strong><\/li>\n<li>Select <strong>Products<\/strong>\u00a0API category and pick\u00a0<strong>ListMatchingProducts<\/strong> API<\/li>\n<li>Enter your <strong>SellerID<\/strong> (i.e. Merchant ID), Developer AccessKey (i.e. <strong>AWSAccessKeyId<\/strong>) and <strong>Secret Key<\/strong> we obtained in the previous section. Enter MarketId (e.g. <strong>ATVPDKIKX0DER<\/strong> for USA Market) and other parameters as below and Click Submit to see response.\n<div id=\"attachment_4844\" style=\"width: 800px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/09\/amazon-mws-api-scratchpad-online-testing-tool.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-4844\" class=\"size-full wp-image-4844\" src=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/09\/amazon-mws-api-scratchpad-online-testing-tool.png\" alt=\"Using Amazon MWS ScratchPad (API Testing Tool - Created by Amazon)\" width=\"790\" height=\"500\" srcset=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/09\/amazon-mws-api-scratchpad-online-testing-tool.png 790w, https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/09\/amazon-mws-api-scratchpad-online-testing-tool-300x190.png 300w, https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/09\/amazon-mws-api-scratchpad-online-testing-tool-768x486.png 768w\" sizes=\"(max-width: 790px) 100vw, 790px\" \/><\/a><p id=\"caption-attachment-4844\" class=\"wp-caption-text\">Using Amazon MWS ScratchPad (API Testing Tool &#8211; Created by Amazon)<\/p><\/div><\/li>\n<li>Click on the <strong>Response Details<\/strong> Tab to extract some important information we will use for ODBC configuration. Notice attributes in red rectangles. They are the ones which we will need in the POST request Body. ZappySys Drivers supply many common parameters automatically but any API endpoint specific parameter must be supplied in the Request Body. For example you dont have to supply <b>SignatureVersion, Timestamp, Signature or SignatureMethod<\/b>\n<div id=\"attachment_4847\" style=\"width: 933px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/09\/amazon-mws-api-response-scratchpad-listmatchingproducts-example.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-4847\" class=\"size-full wp-image-4847\" src=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/09\/amazon-mws-api-response-scratchpad-listmatchingproducts-example.png\" alt=\"Calling Amazon MWS API in Scratchpad Testing Tool (Response Details Tab) - ListMatchingProducts Example\" width=\"923\" height=\"527\" srcset=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/09\/amazon-mws-api-response-scratchpad-listmatchingproducts-example.png 923w, https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/09\/amazon-mws-api-response-scratchpad-listmatchingproducts-example-300x171.png 300w, https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/09\/amazon-mws-api-response-scratchpad-listmatchingproducts-example-768x439.png 768w\" sizes=\"(max-width: 923px) 100vw, 923px\" \/><\/a><p id=\"caption-attachment-4847\" class=\"wp-caption-text\">Calling Amazon MWS API in Scratchpad Testing Tool (Response Details Tab) &#8211; ListMatchingProducts Example<\/p><\/div><\/li>\n<\/ol>\n<p>This API requires Market ID parameter so enter it as per your Market where you selling. For example USA marketplaceid =\u00a0ATVPDKIKX0DER. You can lookup correct MarketplaceId by <a href=\"https:\/\/docs.developer.amazonservices.com\/en_US\/dev_guide\/DG_Endpoints.html\" target=\"_blank\" rel=\"noopener\">checking this help (endpoints \/ marketplaces)<\/a>.<\/p>\n<h3><\/h3>\n<h2>Setup Amazon MWS API Connections<\/h2>\n<div class=\"content_block\" id=\"custom_post_widget-5411\"><h3><span style=\"font-size: 14pt;\">Configure ZappySys Data Gateway<\/span><\/h3>\r\nNow let's look at steps to configure Data Gateway after installation.\r\n<ol style=\"margin-left: 0;\">\r\n \t<li style=\"text-align: left;\">Assuming you have installed\u00a0<a href=\"https:\/\/zappysys.com\/products\/odbc-powerpack\/\" target=\"_blank\" rel=\"noopener\">ZappySys ODBC PowerPack<\/a>\u00a0using default options (Which also enables Data Gateway Service)<\/li>\r\n \t<li style=\"text-align: left;\">Search \"Gateway\" in your start menu and click ZappySys Data Gateway\r\n<div class=\"wp-caption alignnone\"><a href=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/11\/start-menu-open-zappysys-data-gateway.png\">\r\n<img decoding=\"async\" src=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/11\/start-menu-open-zappysys-data-gateway.png\" alt=\"Open ZappySys Data Gateway\" \/><\/a>\r\n<p class=\"wp-caption-text\">Opening ZappySys Data Gateway<\/p>\r\n\r\n<\/div><\/li>\r\n \t<li>First, make sure Gateway Service is running (Verify Start icon is disabled)<\/li>\r\n \t<li>Also, verify Port on General Tab\r\n<div class=\"wp-caption alignnone\"><a href=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/03\/ZappySys-data-gateway-port-5000.png\">\r\n<img decoding=\"async\" src=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/03\/ZappySys-data-gateway-port-5000.png\" alt=\"Port Number setting on ZappySys Data Gateway\" \/><\/a>\r\n<p class=\"wp-caption-text\">Checking port number setting on ZappySys Data Gateway<\/p>\r\n\r\n<\/div><\/li>\r\n \t<li>Now go to Users tab. <strong>Click Add<\/strong> icon to add a new user. Check Is admin to give access to all data sources you add in future. If you don't check admin then you have to manually configure user permission for each data source.\r\n<div class=\"wp-caption alignnone\"><a href=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/11\/zappysys-data-gateway-add-user.png\">\r\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5453\" src=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/11\/gateway-configure-add-user.png\" alt=\"\" width=\"564\" height=\"438\" srcset=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/11\/gateway-configure-add-user.png 564w, https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/11\/gateway-configure-add-user-300x233.png 300w\" sizes=\"(max-width: 564px) 100vw, 564px\" \/><\/a>\r\n<p class=\"wp-caption-text\">Adding the Gateway user<\/p>\r\n\r\n<\/div><\/li>\r\n<\/ol>\r\n&nbsp;<\/div>\n<h3>Create XML Driver Connection for Amazon MWS API (e.g. RequestReport )<\/h3>\n<p>Some APIs we need to call in this article is XML format and some API (e.g. GetReport) is CSV format &#8211; Tab delimited so we need to create 2 different connections using CSV driver and XML driver. So lets get started with Amazon MWS Connection for XML API.<\/p>\n<ol>\n<li>Click on Add New Data source. Name as <strong>AMAZON-MWS-XML<\/strong> and select <a href=\"https:\/\/zappysys.com\/products\/odbc-powerpack\/odbc-xml-soap-api-driver\/\" target=\"_blank\" rel=\"noopener\"><strong>Native &#8211; ZappySys XML Driver<\/strong><\/a> option.\n<div id=\"attachment_5557\" style=\"width: 572px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/11\/odbc_json_driver_add_native_driver.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-5557\" class=\"size-full wp-image-5557\" src=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/11\/odbc_json_driver_add_native_driver.png\" alt=\"Add Gateway Data Source\" width=\"562\" height=\"539\" srcset=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/11\/odbc_json_driver_add_native_driver.png 562w, https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/11\/odbc_json_driver_add_native_driver-300x288.png 300w\" sizes=\"(max-width: 562px) 100vw, 562px\" \/><\/a><p id=\"caption-attachment-5557\" class=\"wp-caption-text\">Add Gateway Data Source<\/p><\/div><\/li>\n<li>Now click Edit to Configure Settings. For now we will only care OAuth Connection settings. All other options are overwritten in SQL Query.\n<div id=\"attachment_5440\" style=\"width: 572px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/11\/gateway-create-datasource-2-2.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-5440\" class=\"size-full wp-image-5440\" src=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/11\/gateway-create-datasource-2-2.png\" alt=\"Edit Gateway Data Source Settings\" width=\"562\" height=\"385\" srcset=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/11\/gateway-create-datasource-2-2.png 562w, https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/11\/gateway-create-datasource-2-2-300x206.png 300w\" sizes=\"(max-width: 562px) 100vw, 562px\" \/><\/a><p id=\"caption-attachment-5440\" class=\"wp-caption-text\">Edit Gateway Data Source Settings<\/p><\/div><\/li>\n<li>When UI opens for Driver Enter MWS API Service URL as below. Notice that we added \/Products\/2011-10-01 (This was extracted from previous section). You can check <a href=\"https:\/\/docs.developer.amazonservices.com\/en_ES\/dev_guide\/DG_Endpoints.html\" target=\"_blank\" rel=\"noopener\">full list of Amazon MWS Endpoints here<\/a>. Because we are connecting to USA region we will use below URL.\n<pre class=\"\">https:\/\/mws.amazonservices.com\/Products\/2011-10-01<\/pre>\n<\/li>\n<li>Select <strong>OAuth<\/strong> from the Connection dropdown and Click <strong>Configure Settings<\/strong><\/li>\n<li>On the Connection UI, Select OAuth Provider\u00a0<strong>Amazon Market Web Service (MWS)<\/strong><\/li>\n<li>Enter your API <strong>Access Key<\/strong> and <strong>Secret Key<\/strong> (obtained <a href=\"https:\/\/sellercentral.amazon.com\/gp\/account-manager\/home.html\/ref=xx_userperms_dnav_userperms\" target=\"_blank\" rel=\"noopener\">from here<\/a>)<\/li>\n<li>Your connection will look like below.\n<div id=\"attachment_4850\" style=\"width: 667px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/09\/amazon-mws-api-odbc-driver-connection.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-4850\" class=\"size-full wp-image-4850\" src=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/09\/amazon-mws-api-odbc-driver-connection.png\" alt=\"ODBC Connection Credentials for Amazon MWS API (Access Key, Secret Key, URL Endpoint)\" width=\"657\" height=\"570\" srcset=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/09\/amazon-mws-api-odbc-driver-connection.png 657w, https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/09\/amazon-mws-api-odbc-driver-connection-300x260.png 300w\" sizes=\"(max-width: 657px) 100vw, 657px\" \/><\/a><p id=\"caption-attachment-4850\" class=\"wp-caption-text\">ODBC Connection Credentials for Amazon MWS API (Access Key, Secret Key, URL Endpoint)<\/p><\/div><\/li>\n<li>Also configure Retry options to handle API limit reached error when you call API too often. For Amazon MWS we get Status code 503 when request is throttled so lets narrow down on which error we want to retry.\n<div id=\"attachment_7156\" style=\"width: 599px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/09\/http-retry-settings-oauth-connection.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-7156\" class=\"size-full wp-image-7156\" src=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/09\/http-retry-settings-oauth-connection.png\" alt=\"Retry Options\" width=\"589\" height=\"429\" srcset=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/09\/http-retry-settings-oauth-connection.png 589w, https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2018\/09\/http-retry-settings-oauth-connection-300x219.png 300w\" sizes=\"(max-width: 589px) 100vw, 589px\" \/><\/a><p id=\"caption-attachment-7156\" class=\"wp-caption-text\">Retry Options<\/p><\/div><\/li>\n<li>Click OK to save OAuth Connection UI to go back to main UI<\/li>\n<li>Now Go to Throttling Tab and enter some delay (e.g. <strong>enter 20000 for 20sec delay after each request<\/strong>). This will slow down API calls so we don&#8217;t face errors about API Limit reached.<\/li>\n<li>Click OK to Save UI<\/li>\n<li>Click Save button on Gateway UI to save and restart<\/li>\n<\/ol>\n<h3>Create CSV Driver Connection for Amazon MWS API (e.g. GetReport )<\/h3>\n<p>Now lets create a connection CSV API (e.g. <a href=\"https:\/\/docs.developer.amazonservices.com\/en_UK\/reports\/Reports_GetReport.html\" target=\"_blank\" rel=\"noopener\">GetReport<\/a> ).<\/p>\n<p>Follow almost same steps as previous section except use CSV Driver when you click on Add new Data source select <strong><a href=\"https:\/\/zappysys.com\/products\/odbc-powerpack\/odbc-csv-rest-api-driver\/\" target=\"_blank\" rel=\"noopener\">Native &#8211; ZappySys CSV Driver<\/a><\/strong> and name data source as <strong>AMAZON-MWS-CSV<\/strong> . As we mentioned for now we mostly want to setup Connection and not worry about Request Body, Pagination etc.<\/p>\n<h3>Create Linked Server for SQL Server<\/h3>\n<p>Run following Script in SSMS to create Linked servers. Change ######## with Your gateway password. Change localhost with machine name or IP where ZappySys Gateway Is running. Use localhost if SQL Server and Gateway both on the same machine.<\/p>\n<pre class=\"lang:tsql decode:true\">USE [master]\r\nGO\r\n\r\nEXEC master.dbo.sp_addlinkedserver @server = N'AMAZON-MWS-XML', @srvproduct=N'', @provider=N'SQLNCLI', @datasrc=N'localhost,5000', @catalog=N'AMAZON-MWS-XML'\r\nEXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'AMAZON-MWS-XML',@useself=N'False',@locallogin=NULL,@rmtuser=N'tdsuser',@rmtpassword='########'\r\nGO\r\n\r\nEXEC master.dbo.sp_addlinkedserver @server = N'AMAZON-MWS-CSV', @srvproduct=N'', @provider=N'SQLNCLI', @datasrc=N'localhost,5000', @catalog=N'AMAZON-MWS-CSV'\r\nEXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'AMAZON-MWS-CSV',@useself=N'False',@locallogin=NULL,@rmtuser=N'tdsuser',@rmtpassword='########'\r\nGO\r\n<\/pre>\n<p>If you want to know how to configure Linked Server using UI then <a href=\"https:\/\/zappysys.com\/blog\/import-rest-api-json-sql-server\/\" target=\"_blank\" rel=\"noopener\">check this article<\/a>.<\/p>\n<p>&nbsp;<\/p>\n<h2>Amazon MWS ListOrders Example<\/h2>\n<p>Now lets look at how to call ListOrders request with pagination in SQL Server. Create a following Stored Procedure to List MWS Orders. If you want to extract many orders then call Report rather than this proc (See next section for generating reports)<\/p>\n<pre class=\"lang:tsql decode:true\">USE MyDatabase\r\nGO\r\n\/*\r\nExample: \r\n exec usp_MWS_ListOrders @SellerId='Axxxxxxx', @MarketplaceId ='Bxxxxxxx',@CreatedAfter='2019-01-01'  \r\n*\/\r\nCreate proc [dbo].[usp_MWS_ListOrders]\r\n\t@SellerId varchar(100),\r\n\t@MarketplaceId varchar(100),\r\n\t@CreatedAfter varchar(100),\r\n\t@CreatedBefore varchar(100)=null,\r\n\t@MaxRows int=0\r\nas\r\ndeclare @sql varchar(max) \r\ndeclare @limitClase varchar(100)=''\r\nif(@MaxRows&gt;0)\r\n\tset @limitClase\t=' LIMIT ' + cast(@MaxRows as varchar(20))\r\n\r\n--\/\/Confirm ISO Date format 2019-06-01T04%3A00%3A00Z  rather 2019-06-01T04:00:00Z\r\nif(isnull(@CreatedAfter,'')&lt;&gt;'')\r\nbegin\r\n\tset @CreatedAfter='&amp;CreatedAfter=' + @CreatedAfter\r\n\tset @CreatedAfter=replace(@CreatedAfter,':','%3A')\r\n\tif(@CreatedAfter NOT LIKE @CreatedAfter + 'T%')\r\n\t\tset @CreatedAfter=@CreatedAfter + 'T00%3A00%3A00Z'\r\n\tif(@CreatedAfter NOT LIKE @CreatedAfter + '%Z')\r\n\t\tset @CreatedAfter=@CreatedAfter + 'Z'\r\n\t--\/\/T04%3A00%3A00Z\r\nend\r\nif(isnull(@CreatedBefore,'')&lt;&gt;'')\r\nbegin\r\n\tset @CreatedBefore='&amp;CreatedBefore=' + @CreatedBefore\r\n\tset @CreatedBefore=replace(@CreatedBefore,':','%3A')\r\n\tif(@CreatedBefore NOT LIKE @CreatedBefore + 'T%')\r\n\t\tset @CreatedBefore=@CreatedBefore + 'T00%3A00%3A00Z'\r\n\tif(@CreatedBefore NOT LIKE @CreatedBefore + '%Z')\r\n\t\tset @CreatedBefore=@CreatedBefore + 'Z'\r\nend\r\n\r\nset @CreatedAfter = isnull(@CreatedAfter,'')\r\nset @CreatedBefore = isnull(@CreatedBefore,'')\r\n\r\n\r\nset @sql = 'SELECT * FROM OPENQUERY([AMAZON-MWS-XML]\r\n, ''\r\nSELECT ReportRequestId FROM $\r\n' + @limitClase +' \r\nWITH(\r\n     Src=''''https:\/\/mws.amazonservices.com\/Orders\/2013-09-01''''\r\n\t,Filter=''''$.RequestReportResponse.RequestReportResult.ReportRequestInfo''''\r\n\t,ElementsToTreatAsArray=''''Order''''\r\n\t,RequestData=''''Action=ListOrders[$tag$]' + @CreatedAfter + @CreatedBefore + '&amp;MarketplaceId.Id.1='+ @MarketplaceId +'&amp;SellerId='+ @SellerId +'''''\r\n\t,RequestMethod=''''POST''''\r\n\t,NextUrlAttributeOrExpr=''''$.ListOrders[$tag$]Response.ListOrders[$tag$]Result.NextToken''''\r\n\t,NextUrlSuffix=''''&amp;NextToken=&lt;%nextlink_encoded%&gt;''''\r\n\t,WaitTimeMs=20000 -- slow down to avoid throttling. 6 requests per min\r\n\t,HasDifferentNextPageInfo=''''True''''\r\n\t,EnablePageTokenForBody=''''True''''\r\n\t,PagePlaceholders=''''body=|ByNextToken;filter=|ByNextToken''''\r\n\t--,DataConnectionType=''''OAuth''''\r\n\t--,ScopeSeparator=''''{space}''''\r\n\t--,ServiceProvider=''''AmazonMWS''''\r\n\t--,ClientId=''''AKIxxxxxx''''\r\n\t--,ClientSecret=''''AKIxxxxxx''''\r\n\t--,UseCustomApp=''''True''''\r\n\t,CacheFileLocation=''''c:\\temp\\mws-orders.cache''''\r\n\t,CacheEntryTtl=300 --send every 5 mins else use from cache\r\n\t,IncludeParentColumns=''''False''''\r\n)\r\n'')'\r\nprint @sql\r\n\r\nEXECUTE( @sql)\r\n<\/pre>\n<p>Here is how to call this proc. Change SellerId, MarketplaceId and Date.<\/p>\n<pre class=\"lang:tsql decode:true\"> exec usp_MWS_ListOrders @SellerId='Axxxxxxx', @MarketplaceId ='Bxxxxxxx',@CreatedAfter='2019-01-01'<\/pre>\n<p>&nbsp;<\/p>\n<h2>Download Amazon MWS Report data in SQL Server (CSV \/ XML Format)<\/h2>\n<p>Now lets look at how to extract data from <a href=\"https:\/\/docs.developer.amazonservices.com\/en_UK\/reports\/Reports_ReportType.html\" target=\"_blank\" rel=\"noopener\">Custom Report API<\/a>\u00a0(You must need ODBC PowerPack <strong>v1.1.1<\/strong> or higher). However reading data from Reports not single step process because report generation is Job style API. Which means you send report request and wait\u00a0 until its done. Once Report ready you have to read in CSV format or XML. Some Reports only available in CSV format.\u00a0<a href=\"https:\/\/docs.developer.amazonservices.com\/en_UK\/reports\/Reports_Overview.html\" target=\"_blank\" rel=\"noopener\">Check this post<\/a> to understand how complex it can be to get data. We will make it simple for you to understand this in 3 steps. Basically calling reports requires minimum 3 API calls (see below)<\/p>\n<ol>\n<li>Create a new report request &#8211; Cal\u00a0<a href=\"https:\/\/docs.developer.amazonservices.com\/en_UK\/reports\/Reports_RequestReport.html\" target=\"_blank\" rel=\"noopener\">RequestReport<\/a>\u00a0API . It returns <strong>ReportRequestId<\/strong> (You can use it in the next step)<\/li>\n<li>Check Report Status see its done &#8211; Call <a href=\"https:\/\/docs.developer.amazonservices.com\/en_UK\/reports\/Reports_GetReportRequestList.html\" target=\"_blank\" rel=\"noopener\">GetReportRequestList<\/a>\u00a0API (Pass <strong>ReportRequestId<\/strong> got in the previous step to get data for only one Report request we care). Keep checking Report Status every few seconds until you get <strong>_DONE_<\/strong>\u00a0 or <strong>_DONE_NO_DATA_<\/strong> status in response.<\/li>\n<li>Read Report Data &#8211; Call <a href=\"https:\/\/docs.developer.amazonservices.com\/en_UK\/reports\/Reports_GetReport.html\" target=\"_blank\" rel=\"noopener\">GetReport<\/a>. This API call returns CSV or XML data. So use correct Driver for this step. If CSV data is returned then we must use CSV Driver rather than XML Driver.<\/li>\n<\/ol>\n<h3>Method 1 &#8211; Single query approach (New Driver)<\/h3>\n<p>In new driver ZappySys added few new features which makes it possible to call above 3 steps process in a single query. New query syntax offers StatusCheck and Mixing Content Formats using same driver. Because Most MWS Reports are in CSV Format we have to use CSV Driver but oddly first 2 steps listed in above sections are in XML Format so we have to use XML driver. Technically we need atleast 2 steps (i.e 2 queries) but we will show you how to achieve using single query as below.<\/p>\n<ol>\n<li>Assuming you have followed steps to create a linked server AMAZON-MWS-CSV (see previous section)<\/li>\n<li>Run below query. Replace necessary parameters as per your need. (i.e MarketplaceId , SellerId, CreatedAfter date)\n<pre class=\"lang:tsql decode:true\">--- \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\r\n-- Change _GET_MERCHANT_LISTINGS_DATA_ to something else if you need different report type (all 3 steps) -- https:\/\/docs.developer.amazonservices.com\/en_US\/reports\/Reports_ReportType.html\r\n-- Replace MarketplaceId in all 3 steps (i.e for USA use ATVPDKIKX0DER) --https:\/\/docs.developer.amazonservices.com\/en_US\/dev_guide\/DG_Endpoints.html\r\n-- Replace SellerId in all 3 steps\r\n-- Remove or Change CreatedAfter in first step (or use CreatedBefore parameter instread of CreatedAfter)\r\n--- \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\r\nselect * into tmpMWS_Report from OPENQUERY([AMAZON-MWS-CSV],\r\n'\r\nSELECT s3.* FROM $\r\nWITH(\r\nSrc=''https:\/\/mws.amazonservices.com\/Reports\/2009-01-01'',RequestMethod=''POST''\r\n,RequestData=''Action=RequestReport&amp;ReportType=_GET_MERCHANT_LISTINGS_DATA_&amp;MarketplaceId=ATVPDKIKX0DER&amp;SellerId=Axxxxxxxxxx&amp;CreatedAfter=2017-12-31T04%3A00%3A00Z''\r\n,IncludeParentColumns=''False''\r\n,EnableRawOutputModeSingleRow=''True''\r\n,RawOutputFilterExpr=''\/\/*[local-name()=\"ReportRequestId\"]'' \r\n,RawOutputDataRowTemplate=''{ReportRequestId:\"[$1]\"}'' \r\n,RawOutputExtractMode=''Xml'' \r\n,WaitTimeMs=5000\r\n,Meta=''[{\"Name\": \"ReportRequestId\",\"Type\": \"Int64\"}]''\r\n,Alias=''s1''\r\n\r\n,Join1_alias=''s2''\t\r\n,Join1_Src=''https:\/\/mws.amazonservices.com\/Reports\/2009-01-01'',Join1_RequestMethod=''POST''\r\n,Join1_RequestData=''Action=GetReportRequestList&amp;ReportRequestIdList.Id.1=[$s1.ReportRequestId$]&amp;MarketplaceId=ATVPDKIKX0DER&amp;SellerId=Axxxxxxxxxxxxx''\r\n,Join1_EnableRawOutputModeSingleRow=''True''\r\n,Join1_RawOutputFilterExpr=''\/\/*[local-name()=\"ReportProcessingStatus\"]||\/\/*[local-name()=\"GeneratedReportId\"]'' \r\n,Join1_RawOutputDataRowTemplate=''{ReportProcessingStatus:\"[$1]\",GeneratedReportId:\"[$2]\"}'' \r\n,Join1_RawOutputExtractMode=''Xml'' \r\n,Join1_EnableStatusCheck=''True'', \r\n,Join1_StatucCheckMaxWaitSeconds=300,\r\n,Join1_StatucCheckIterationWaitSeconds=25,\r\n,Join1_StatusSuccessValue=''_DONE_''\r\n,Join1_StatusFailedValue=''_DONE_NO_DATA_|_CANCELLED_''\r\n\r\n,Join2_Alias=''s3''\r\n,Join2_Src=''https:\/\/mws.amazonservices.com\/Reports\/2009-01-01'',Join2_RequestMethod=''POST''\r\n,Join2_RequestData=''Action=GetReport&amp;ReportId=[$s2.GeneratedReportId$]&amp;MarketplaceId=ATVPDKIKX0DER&amp;SellerId=Axxxxxxxxxxxxxx''\t\r\n,Join2_ColumnDelimiter=''{TAB}''\r\n,Join2_ResponseCharset=''Windows-1252''\t \r\n,Join2_EnableStatusCheck=''False'' \r\n,Join2_EnableRawOutputModeSingleRow=''False''\r\n,Join2_WaitTimeMs=10000\r\n)') \r\ngo\r\nselect * from tmpMWS_Report<\/pre>\n<p>&nbsp;<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<p><strong>Performance Tip<\/strong><\/p>\n<p>If you like to improve performance and dont want to use SELECT INTO approach to load into temp table as above then you can use EXEC (&#8230;.) AT YourLinkedServerName\u00a0 as below.<\/p>\n<p>Advantage of this method is your Query speed will increase because system calls API only once when you call EXEC AT. In OPENROWSET it needs to call above query twice (Once to obtain metadata and once to get data).<\/p>\n<pre class=\"lang:tsql decode:true \">INSERT INTO tmpMWS_Report\r\nEXEC('select s3.* .................. ') AT [AMAZON-MWS-CSV]<\/pre>\n<div class=\"su-note\"  style=\"border-color:#e5de9d;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#fff8b7;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">When you use OPENQUERY \/ EXEC..AT with Data Gateway there is a known limitation with SQL Query Length. Your query must be less than 2048 characters otherwise you may get [**** Data is invalid error ****] Try to avoid column names for long query and use SELECT * INTO temp_table FROM OPENQUERY(&#8230;..) approach. <\/div><\/div>\n<p>&nbsp;<\/p>\n<h3>Method 2 &#8211; Multiple query approach (For old driver)<\/h3>\n<p>Now lets see how to load Amazon MWS data in SQL Server using <strong>old driver<\/strong>\u00a0(<strong>v1.1.2 or older<\/strong>) which didnt support single query approach like previous section. If you are using older driver or for some reason you like to split steps into multiple procedures then use below approach.<\/p>\n<h4>usp_MWS_Report\u00a0 Stored Proc ( Generate ReportRequest, Wait until done, Read data )<\/h4>\n<pre class=\"lang:tsql decode:true\">USE MyDatabase\r\nGO\r\n\r\n\/*\r\nExamples: \r\nGet ReportType from here https:\/\/docs.developer.amazonservices.com\/en_UK\/reports\/Reports_ReportType.html\r\n\r\nexec usp_MWS_Report @MarketplaceId ='ATVPDKIKX0DER', @SellerId='AZxxxxxxxx', @ReportType = '_GET_MERCHANT_LISTINGS_DATA_'\r\nexec usp_MWS_Report @MarketplaceId ='ATVPDKIKX0DER', @SellerId='AZxxxxxxxx', @ReportType = '_GET_FLAT_FILE_ORDER_REPORT_DATA_'\r\n\r\n--Do not Throw Error if no data found (return empty resultset or run custom sql)\r\nexec usp_MWS_Report @MarketplaceId ='ATVPDKIKX0DER', @SellerId='AZxxxxxxxx', @ReportType = '_GET_FLAT_FILE_ORDER_REPORT_DATA_',@ThrowErrIfNoData=0,@EmptyRowSql='select top 0 * from Orders'\r\n--Supply date range\r\nexec usp_MWS_Report @MarketplaceId ='ATVPDKIKX0DER', @SellerId='AZxxxxxxxx', @ReportType = '_GET_MERCHANT_LISTINGS_DATA_', @StartDate='2019-01-01T00:00:00Z', @EndDate='2019-01-31T00:00:00Z'\r\n\r\n--loading into table \r\n\r\n--\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\r\n\u2014 Step-1 : Create Local Linked server to point to self\r\n--\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\r\nUSE [master]\r\nGO\r\n--change default catalog\r\n--For MSSQL 2012, 2014, 2016, 2017, and 2019 use @provider=N'MSOLEDBSQL' below (SQL Server Native Client 11.0)---\r\nEXEC master.dbo.sp_addlinkedserver @server = N'ME', @srvproduct=N'', @provider=N'SQLNCLI11', @datasrc=N'localhost', @catalog=N'Northwind'\r\n--For MSSQL 2022 or higher use @provider=N'MSOLEDBSQL' below (Microsoft OLE DB Driver for SQL Server)---\r\n--EXEC master.dbo.sp_addlinkedserver @server = N'ME', @srvproduct=N'', @provider=N'MSOLEDBSQL', @datasrc=N'localhost', @catalog=N'Northwind'\r\n\r\nEXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'ME',@useself=N'True',@locallogin=NULL,@rmtuser=NULL,@rmtpassword=NULL\r\nGO\r\n--\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\r\n\u2014 Step-2 : Enable RPC OUT and Disable MSDTC\r\n--\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\r\nEXEC sp_serveroption 'ME', 'rpc out', true;  \r\nGO\r\n--Below needed to support EXEC + INSERT (dynamic query)\r\nEXEC sp_serveroption 'ME', 'remote proc transaction promotion', false;\r\nGO\r\n--test simple query\r\nselect * from OPENQUERY(ME,'select 1')\r\nGO\r\n\r\n--\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\r\n\u2014 Step-3 : Load data into table from MWS Report\r\n--\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\r\nSELECT * INTO #amazon_mws_report\r\nFROM OPENQUERY(me,'\r\nSET NOCOUNT ON;\r\nEXEC usp_MWS_Report \r\n   @Columns=''[item-name], [item-description], [listing-id]'',\r\n   @MarketplaceId =''ATVPDKIKX0DER'', \r\n   @SellerId=''Axxxxxxxxxxxxxxxxx'', \r\n   @ReportType = ''_GET_MERCHANT_LISTINGS_DATA_''\r\nWITH RESULT SETS \r\n(\r\n\t(itmname varchar(1000),itmdesc varchar(1000),itmid varchar(1000))\r\n)\r\n')\r\n\r\nselect * from #amazon_mws_report\r\n\r\n\r\n*\/\r\nCREATE proc [dbo].[usp_MWS_Report]\r\n\t@MarketplaceId varchar(100),\r\n\t@SellerId varchar(100),\r\n\t@ReportType varchar(100)='_GET_MERCHANT_LISTINGS_DATA_',\r\n\t@StartDate varchar(100)=null,\r\n\t@EndDate varchar(100)=null,\r\n\t@ReportId bigint=null,  ---i.e. 14783134522018025\r\n\t@ThrowErrIfNoData bit=1,\r\n\t@EmptyRowSql varchar(1000)=null, --SQL to run if no data found\r\n\t@Columns varchar(8000)='*'  --report columns which goes in final SELECT  e.g. [item-name], [item-description], [listing-id] ....\r\nas\r\n\r\n\r\ndeclare @retGeneratedReportId bigint\r\nset @retGeneratedReportId=@ReportId\r\n---\/\/\/\/\/\/ STEP 1 \/\/\/\/\/\/\/\/\/\r\nif(@ReportId is null)\r\nbegin\r\n\tcreate table #step1(ReportRequestId bigint)\r\n\tinsert into #step1\r\n\texec usp_MWS_RequestReport @ReportType,@MarketplaceId,@SellerId,@StartDate,@EndDate\r\n\r\n\t--select * from #step1 --debug\r\n\r\n\tdeclare @retReportRequestId bigint\r\n\tselect @retReportRequestId=ReportRequestId from #step1\r\n\r\n\t---\/\/\/\/\/\/ STEP 2 \/\/\/\/\/\/\/\/\/\r\n\tdeclare @status varchar(100)\r\n\tdeclare @cnt int\r\n\tcreate table #step2(ReportProcessingStatus varchar(100),GeneratedReportId bigint)\r\n\t\r\n\t--Keep looping until status is done or we waited too long\r\n\twhile(isnull(@status,'') IN ('','_SUBMITTED_','_IN_PROGRESS_') )\r\n\tbegin\r\n\t\ttruncate table #step2\r\n\t\tinsert into #step2\r\n\t\texec usp_MWS_GetReportIdAndStatus @retReportRequestId,@MarketplaceId,@SellerId \r\n\t\r\n\t\tselect @status=ReportProcessingStatus, @retGeneratedReportId=GeneratedReportId from #step2\r\n\t\tif(isnull(@status,'') IN ('','_SUBMITTED_','_IN_PROGRESS_') )\t\t\t\r\n\t\tbegin\r\n\t\t\t--amazon says dont check often https:\/\/docs.developer.amazonservices.com\/en_UK\/reports\/Reports_GetReportRequestList.html\r\n\t\t\tPrint 'Status='+  isnull(@status,'') +'. Checking after 45 sec... #' + cast(@cnt as varchar(10))\r\n\t\t\tWAITFOR DELAY '00:00:45'\t\t\t\r\n\t\tend\r\n\t\telse\r\n\t\t\tprint @status\r\n\r\n\t\tset @cnt=@cnt+1\r\n\r\n\t\t--if(@cnt&gt;50)\r\n\t\t\t--\/\/throw err?\r\n\tend\r\n\t--select * from #step2 --debug\r\nend\r\n\r\nif(@retGeneratedReportId is null and @status='_DONE_NO_DATA_')\r\nbegin\r\n\tif(@ThrowErrIfNoData=1)\r\n\t\tRAISERROR('Cannot generate report - No data found for specified criteria',16,1); \r\n\telse if (isnull(@EmptyRowSql,'')&lt;&gt;'')\r\n\t\texecute(@EmptyRowSql)\r\nend\r\nelse if(@retGeneratedReportId is null)\r\n\tRAISERROR('Cannot generate report - Unknown error (either report got cancelled or other error occurred)',16,1); \r\n\r\n\t\r\n---\/\/\/\/\/\/ STEP 3 \/\/\/\/\/\/\/\/\/\r\n--If xml format of report data then use XML driver else CSV (most are Tab delimited reports in CSV format)\r\n--exec usp_MWS_GetReportDataXml @retGeneratedReportId,@MarketplaceId,@SellerId\r\nexec usp_MWS_GetReportDataCsv @retGeneratedReportId,@MarketplaceId,@SellerId,@Columns\r\n\r\ndrop table #step1\r\ndrop table #step2\r\n\r\nGO<\/pre>\n<p>&nbsp;<\/p>\n<h4>usp_MWS_RequestReport\u00a0 Stored Proc ( Step1 &#8211; Create Report Request )<\/h4>\n<p>&nbsp;<\/p>\n<pre class=\"lang:tsql decode:true\">USE [MyDatabase]\r\nGO\r\n\r\nCREATE proc [dbo].[usp_MWS_RequestReport]\r\n\t@ReportType varchar(100),\r\n\t@MarketplaceId varchar(100),\r\n\t@SellerId varchar(100),\r\n\t@StartDate varchar(100)=null,\r\n\t@EndDate varchar(100)=null\r\nas\r\n\r\n\/*Learn more : https:\/\/docs.developer.amazonservices.com\/en_UK\/reports\/Reports_RequestReport.html *\/\r\n\r\n--\/\/Confirm ISO Date format 2019-06-01T04%3A00%3A00Z  rather 2019-06-01T04:00:00Z\r\nif(isnull(@StartDate,'')&lt;&gt;'')\r\nbegin\r\n\tset @StartDate='&amp;StartDate=' + @StartDate\r\n\tset @StartDate=replace(@StartDate,':','%3A')\r\n\tif(@StartDate NOT LIKE @StartDate + 'T%')\r\n\t\tset @StartDate=@StartDate + 'T00%3A00%3A00Z'\r\n\tif(@StartDate NOT LIKE @StartDate + '%Z')\r\n\t\tset @StartDate=@StartDate + 'Z'\r\n\t--\/\/T04%3A00%3A00Z\r\nend\r\nif(isnull(@EndDate,'')&lt;&gt;'')\r\nbegin\r\n\tset @EndDate='&amp;EndDate=' + @EndDate\r\n\tset @EndDate=replace(@EndDate,':','%3A')\r\n\tif(@EndDate NOT LIKE @EndDate + 'T%')\r\n\t\tset @EndDate=@EndDate + 'T00%3A00%3A00Z'\r\n\tif(@EndDate NOT LIKE @EndDate + '%Z')\r\n\t\tset @EndDate=@EndDate + 'Z'\r\nend\r\n\r\nset @StartDate = isnull(@StartDate,'')\r\nset @EndDate = isnull(@EndDate,'')\r\n\r\ndeclare @sql varchar(max) \r\nset @sql = 'SELECT * FROM OPENQUERY([AMAZON-MWS-XML]\r\n, ''\r\nSELECT ReportRequestId FROM $\r\nWITH(\r\n\tSrc=''''https:\/\/mws.amazonservices.com\/Reports\/2009-01-01'''',RequestMethod=''''POST''''\r\n\t--,ElementsToTreatAsArray=''''Product''''\r\n\t,Filter=''''$.RequestReportResponse.RequestReportResult.ReportRequestInfo''''\r\n\t,RequestData=''''Action=RequestReport&amp;ReportType=' + @ReportType  + '&amp;MarketplaceId='+ @MarketplaceId +'&amp;SellerId='+ @SellerId + @StartDate + @EndDate +'''''\r\n\t,CacheFileLocation=''''c:\\temp\\mws-cache-step-1.cache''''\r\n\t,CacheEntryTtl=300 --send every 5 mins else use from cache\r\n\t,WaitTimeMs=''''300''''\r\n\t,IncludeParentColumns=''''False''''\r\n\t,Meta=''''[{\"Name\": \"ReportRequestId\",\"Type\": \"Int64\"}]''''\r\n)'')'\r\n--print @sql\r\n\r\nEXECUTE( @sql)\r\n--sleep 25 seconds after this - hope report is ready by that time else We have to loop\r\nWAITFOR DELAY '00:00:25'  --lets wait 30 sec... incase we get luck and report is done?\r\nGO<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h4>usp_MWS_GetReportIdAndStatus Stored Proc ( Step2 &#8211; Get Report Id and Report Status )<\/h4>\n<p>&nbsp;<\/p>\n<pre class=\"lang:tsql decode:true\">USE MyDatabase\r\nGO\r\n\r\n\r\nCREATE proc [dbo].[usp_MWS_GetReportIdAndStatus]\r\n\t@ReportRequestId bigint,\r\n\t@MarketplaceId varchar(100),\r\n\t@SellerId varchar(100)\r\nas\r\n\r\ndeclare @sql varchar(max) \r\nset @sql = 'SELECT * FROM OPENQUERY([AMAZON-MWS-XML]\r\n, ''SELECT *  FROM $\r\nWITH(\r\n\t Src=''''https:\/\/mws.amazonservices.com\/Reports\/2009-01-01'''',RequestMethod=''''POST''''\r\n\t,ElementsToTreatAsArray=''''ReportRequestInfo''''\r\n\t,Filter=''''$.GetReportRequestListResponse.GetReportRequestListResult.ReportRequestInfo''''\r\n\t,RequestData=''''Action=GetReportRequestList&amp;ReportRequestIdList.Id.1=' + cast(@ReportRequestId as varchar(20)) + '&amp;MarketplaceId='+ @MarketplaceId +'&amp;SellerId='+ @SellerId +'''''\r\n\t,WaitTimeMs=''''300''''\r\n\t,IncludeParentColumns=''''False''''\r\n\t--,CacheFileLocation=''''c:\\temp\\mws-cache-step-2.cache''''\r\n\t--,CacheEntryTtl=10  --do not use from cache too old.. but cache still prevents too many requests\r\n\t,Meta=''''[{\"Name\": \"ReportProcessingStatus\",\"Type\": \"String\", Length: 100},{\"Name\": \"GeneratedReportId\",\"Type\": \"Int64\"}]''''\t\r\n)'')'\r\n\r\n--print @sql\r\n\r\nEXECUTE( @sql)\r\n\r\nGO<\/pre>\n<p>&nbsp;<\/p>\n<h4>usp_MWS_GetReportDataCsv Stored Proc (Step3 &#8211; Get Report Data in CSV format )<\/h4>\n<p>Last step in report generation is download the report data in CSV format.<\/p>\n<pre class=\"lang:tsql decode:true\">USE MyDatabase\r\nGO\r\n\r\nCREATE proc [dbo].[usp_MWS_GetReportDataCsv]\r\n\t@ReportId bigint,\r\n\t@MarketplaceId varchar(100),\r\n\t@SellerId varchar(100),\r\n\t@Columns varchar(8000)='*'\r\n\r\nas\r\n\r\ndeclare @sql varchar(max) \r\nset @sql = 'SELECT '+ @Columns +' FROM OPENQUERY([AMAZON-MWS-CSV], \r\n''SELECT * FROM $\r\nWITH(\r\n    Src=''''https:\/\/mws.amazonservices.com\/Reports\/2009-01-01'''',RequestMethod=''''POST''''\r\n\t,RequestData=''''Action=GetReport&amp;ReportId=' + cast(@ReportId as varchar(20)) + '&amp;MarketplaceId='+ @MarketplaceId +'&amp;SellerId='+ @SellerId +'''''\r\n\t,WaitTimeMs=''''300''''\r\n\t,ColumnDelimiter=''''{TAB}''''\r\n\t,ResponseCharset=''''Windows-1252''''\t\r\n\t,CacheFileLocation=''''c:\\temp\\mws-cache-step-3.cache''''\r\n\t,CacheEntryTtl=300 --once report is generated lets try to read from cache \r\n\t)''\r\n)'\r\n\r\nprint @sql\r\n\r\nEXECUTE( @sql)\r\nGO<\/pre>\n<p>&nbsp;<\/p>\n<h4>Example &#8211; Import data from Amazon MWS into SQL Server Table<\/h4>\n<p>Finally when we have all stored procs created we can load into target table as below. In our previous article we saw how to use SELECT INTO along with OPENQUERY to load data into new temp table or insert into some existing table. However when you want to load Stored Proc output into table its not straight forward specially when we calling dynamic SQL.<\/p>\n<p>Three tricks worth mentioning here which makes it possible to load data from stored proc into temp table dynamically.<\/p>\n<ol>\n<li>Create a linked server to Self so we can use OPENQUERY against to call stored proc so its easy to use <strong>SELECT INTO<\/strong>.<\/li>\n<li>Use <strong>WITH RESULT SETS<\/strong> to describe metadata of output. This is needed because we are using dynamic SQL inside proc and WITH RESULT SETS describes the metadata.<\/li>\n<li>Use of SET NO COUNT ON to avoid error like below\n<pre class=\"lang:default decode:true\">\"SOMESERVERNAME\" indicates that either the object has no columns \r\nor the current user does not have permissions on that object<\/pre>\n<\/li>\n<li>If you dont do above tricks then you may see errors like <a href=\"https:\/\/stackoverflow.com\/questions\/3795263\/errors-insert-exec-statement-cannot-be-nested-and-cannot-use-the-rollback-s\" target=\"_blank\" rel=\"noopener\">this<\/a> (INSERT is not allowed when we use DYNAMIC SQL inside nested Stored Procs)<\/li>\n<\/ol>\n<p>To load output into table you must know column names from the output.\u00a0 If you dont know you can try to run stored proc without @Columns like below.<\/p>\n<pre class=\"lang:tsql decode:true\">EXEC usp_MWS_Report @MarketplaceId =''ATVPDKIKX0DER'', @SellerId=''Axxxxxxxxxxxxx'', @ReportType = ''_GET_MERCHANT_LISTINGS_DATA_''<\/pre>\n<p>Once we know columns from report, you can run following script to insert into table.<\/p>\n<p><strong>Full Script &#8211; Load MWS Report Output into Table<\/strong><\/p>\n<pre class=\"lang:tsql decode:true \">--\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\r\n\u2014 Step-1 : Create Local Linked server to point to self\r\n--\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\r\nUSE [master]\r\nGO\r\n--change default catalog\r\n--For MSSQL 2012, 2014, 2016, 2017, and 2019 use @provider=N'MSOLEDBSQL' below (SQL Server Native Client 11.0)---\r\nEXEC master.dbo.sp_addlinkedserver @server = N'ME', @srvproduct=N'', @provider=N'SQLNCLI11', @datasrc=N'localhost', @catalog=N'Northwind'\r\n--For MSSQL 2022 or higher use @provider=N'MSOLEDBSQL' below (Microsoft OLE DB Driver for SQL Server)---\r\n--EXEC master.dbo.sp_addlinkedserver @server = N'ME', @srvproduct=N'', @provider=N'MSOLEDBSQL', @datasrc=N'localhost', @catalog=N'Northwind'\r\n\r\nEXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'ME',@useself=N'True',@locallogin=NULL,@rmtuser=NULL,@rmtpassword=NULL\r\nGO\r\n--\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\r\n\u2014 Step-2 : Enable RPC OUT and Disable MSDTC\r\n--\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\r\nEXEC sp_serveroption 'ME', 'rpc out', true;  \r\nGO\r\n--Below needed to support EXEC + INSERT (dynamic query)\r\nEXEC sp_serveroption 'ME', 'remote proc transaction promotion', false;\r\nGO\r\n--test simple query\r\nselect * from OPENQUERY(ME,'select 1')\r\nGO\r\n\r\n--\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\r\n\u2014 Step-3 : Load data into temp table from Amazon MWS Report\r\n--\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\r\nSELECT * INTO #amazon_mws_report\r\nFROM OPENQUERY(me,'\r\nSET NOCOUNT ON;\r\nEXEC usp_MWS_Report \r\n   @Columns=''[item-name], [item-description], [listing-id]'',\r\n   @MarketplaceId =''ATVPDKIKX0DER'', \r\n   @SellerId=''Axxxxxxxxxxxxx'', \r\n   @ReportType = ''_GET_MERCHANT_LISTINGS_DATA_''\r\nWITH RESULT SETS \r\n(\r\n\t(itmname varchar(1000),itmdesc varchar(1000),itmid varchar(1000))\r\n)\r\n')\r\n\r\nselect * from #amazon_mws_report\r\n<\/pre>\n<div id=\"attachment_7192\" style=\"width: 865px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2019\/05\/import-amazon-mws-data-into-sql-server-table-generate-report.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-7192\" class=\"size-full wp-image-7192\" src=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2019\/05\/import-amazon-mws-data-into-sql-server-table-generate-report.png\" alt=\"Import Amazon MWS Data into SQL Table (Load Report output into temp table)\" width=\"855\" height=\"499\" srcset=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2019\/05\/import-amazon-mws-data-into-sql-server-table-generate-report.png 855w, https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2019\/05\/import-amazon-mws-data-into-sql-server-table-generate-report-300x175.png 300w, https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2019\/05\/import-amazon-mws-data-into-sql-server-table-generate-report-768x448.png 768w\" sizes=\"(max-width: 855px) 100vw, 855px\" \/><\/a><p id=\"caption-attachment-7192\" class=\"wp-caption-text\">Import Amazon MWS Data into SQL Table (Load Report output into temp table)<\/p><\/div>\n<h2>Conclusion<\/h2>\n<p>In this article, we saw how to load Amazon MWS Data into SQL Server. We used simple SQL queries with ZappySys XML \/ CSV Driver to pull data from Amazon MWS API.\u00a0<a href=\"https:\/\/zappysys.com\/products\/odbc-powerpack\/\">ZappySys ODBC PowerPack<\/a> makes it super easy to consume data from virtually any API (JSON \/ XML or CSV Web Services), no coding required. <a href=\"https:\/\/zappysys.com\/products\/odbc-powerpack\/download\/\">Download here<\/a> to get started with ZappySys ODBC drivers.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction In our previous blog post we saw how to import rest API in SQL Server. Using same concepts lets look at how to import Amazon MWS Data into SQL Server. We will explore many techniques to call Amazon MWS API and learn how to automate Amazon MWS data extraction without doing any ETL. We [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1632,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[392,380,347,278],"tags":[151,287,494,493],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\r\n<title>How to import Amazon MWS data into SQL Server (T-SQL) | ZappySys Blog<\/title>\r\n<meta name=\"description\" content=\"Learn how to import Amazon MWS data into SQL Server. ListOrders and Generate Reports to query data from MWS using T-SQL Code. Load \/ Download CSV \/ Reports\" \/>\r\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\r\n<link rel=\"canonical\" href=\"https:\/\/zappysys.com\/blog\/import-amazon-mws-data-sql-server-t-sql\/\" \/>\r\n<meta property=\"og:locale\" content=\"en_US\" \/>\r\n<meta property=\"og:type\" content=\"article\" \/>\r\n<meta property=\"og:title\" content=\"How to import Amazon MWS data into SQL Server (T-SQL) | ZappySys Blog\" \/>\r\n<meta property=\"og:description\" content=\"Learn how to import Amazon MWS data into SQL Server. ListOrders and Generate Reports to query data from MWS using T-SQL Code. Load \/ Download CSV \/ Reports\" \/>\r\n<meta property=\"og:url\" content=\"https:\/\/zappysys.com\/blog\/import-amazon-mws-data-sql-server-t-sql\/\" \/>\r\n<meta property=\"og:site_name\" content=\"ZappySys Blog\" \/>\r\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/ZappySys\/\" \/>\r\n<meta property=\"article:published_time\" content=\"2019-05-30T15:37:37+00:00\" \/>\r\n<meta property=\"article:modified_time\" content=\"2026-03-11T07:08:29+00:00\" \/>\r\n<meta property=\"og:image\" content=\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2016\/10\/amazon-mws-api-integration.png\" \/>\r\n\t<meta property=\"og:image:width\" content=\"505\" \/>\r\n\t<meta property=\"og:image:height\" content=\"505\" \/>\r\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\r\n<meta name=\"author\" content=\"ZappySys\" \/>\r\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\r\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/zappysys\/\" \/>\r\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"ZappySys\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"12 minutes\" \/>\r\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/zappysys.com\/blog\/import-amazon-mws-data-sql-server-t-sql\/\",\"url\":\"https:\/\/zappysys.com\/blog\/import-amazon-mws-data-sql-server-t-sql\/\",\"name\":\"How to import Amazon MWS data into SQL Server (T-SQL) | ZappySys Blog\",\"isPartOf\":{\"@id\":\"https:\/\/zappysys.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/zappysys.com\/blog\/import-amazon-mws-data-sql-server-t-sql\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/zappysys.com\/blog\/import-amazon-mws-data-sql-server-t-sql\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2016\/10\/amazon-mws-api-integration.png\",\"datePublished\":\"2019-05-30T15:37:37+00:00\",\"dateModified\":\"2026-03-11T07:08:29+00:00\",\"author\":{\"@id\":\"https:\/\/zappysys.com\/blog\/#\/schema\/person\/2756c237457fbc95d82cb38962f81f82\"},\"description\":\"Learn how to import Amazon MWS data into SQL Server. ListOrders and Generate Reports to query data from MWS using T-SQL Code. Load \/ Download CSV \/ Reports\",\"breadcrumb\":{\"@id\":\"https:\/\/zappysys.com\/blog\/import-amazon-mws-data-sql-server-t-sql\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/zappysys.com\/blog\/import-amazon-mws-data-sql-server-t-sql\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/zappysys.com\/blog\/import-amazon-mws-data-sql-server-t-sql\/#primaryimage\",\"url\":\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2016\/10\/amazon-mws-api-integration.png\",\"contentUrl\":\"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2016\/10\/amazon-mws-api-integration.png\",\"width\":505,\"height\":505},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/zappysys.com\/blog\/import-amazon-mws-data-sql-server-t-sql\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/zappysys.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to import Amazon MWS data into SQL Server (T-SQL)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/zappysys.com\/blog\/#website\",\"url\":\"https:\/\/zappysys.com\/blog\/\",\"name\":\"ZappySys Blog\",\"description\":\"SSIS \/ ODBC Drivers \/ API Connectors for JSON, XML, Azure, Amazon AWS, Salesforce, MongoDB and more\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/zappysys.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/zappysys.com\/blog\/#\/schema\/person\/2756c237457fbc95d82cb38962f81f82\",\"name\":\"ZappySys\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/zappysys.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/5c9be148088ba9b8af8e955c5f7c22b5?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/5c9be148088ba9b8af8e955c5f7c22b5?s=96&d=mm&r=g\",\"caption\":\"ZappySys\"},\"sameAs\":[\"http:\/\/www.zappysys.com\/\",\"https:\/\/www.facebook.com\/ZappySys\/\",\"https:\/\/twitter.com\/https:\/\/twitter.com\/zappysys\/\"],\"url\":\"https:\/\/zappysys.com\/blog\/author\/admin\/\"}]}<\/script>\r\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to import Amazon MWS data into SQL Server (T-SQL) | ZappySys Blog","description":"Learn how to import Amazon MWS data into SQL Server. ListOrders and Generate Reports to query data from MWS using T-SQL Code. Load \/ Download CSV \/ Reports","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:\/\/zappysys.com\/blog\/import-amazon-mws-data-sql-server-t-sql\/","og_locale":"en_US","og_type":"article","og_title":"How to import Amazon MWS data into SQL Server (T-SQL) | ZappySys Blog","og_description":"Learn how to import Amazon MWS data into SQL Server. ListOrders and Generate Reports to query data from MWS using T-SQL Code. Load \/ Download CSV \/ Reports","og_url":"https:\/\/zappysys.com\/blog\/import-amazon-mws-data-sql-server-t-sql\/","og_site_name":"ZappySys Blog","article_author":"https:\/\/www.facebook.com\/ZappySys\/","article_published_time":"2019-05-30T15:37:37+00:00","article_modified_time":"2026-03-11T07:08:29+00:00","og_image":[{"width":505,"height":505,"url":"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2016\/10\/amazon-mws-api-integration.png","type":"image\/png"}],"author":"ZappySys","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/zappysys\/","twitter_misc":{"Written by":"ZappySys","Est. reading time":"12 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/zappysys.com\/blog\/import-amazon-mws-data-sql-server-t-sql\/","url":"https:\/\/zappysys.com\/blog\/import-amazon-mws-data-sql-server-t-sql\/","name":"How to import Amazon MWS data into SQL Server (T-SQL) | ZappySys Blog","isPartOf":{"@id":"https:\/\/zappysys.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/zappysys.com\/blog\/import-amazon-mws-data-sql-server-t-sql\/#primaryimage"},"image":{"@id":"https:\/\/zappysys.com\/blog\/import-amazon-mws-data-sql-server-t-sql\/#primaryimage"},"thumbnailUrl":"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2016\/10\/amazon-mws-api-integration.png","datePublished":"2019-05-30T15:37:37+00:00","dateModified":"2026-03-11T07:08:29+00:00","author":{"@id":"https:\/\/zappysys.com\/blog\/#\/schema\/person\/2756c237457fbc95d82cb38962f81f82"},"description":"Learn how to import Amazon MWS data into SQL Server. ListOrders and Generate Reports to query data from MWS using T-SQL Code. Load \/ Download CSV \/ Reports","breadcrumb":{"@id":"https:\/\/zappysys.com\/blog\/import-amazon-mws-data-sql-server-t-sql\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/zappysys.com\/blog\/import-amazon-mws-data-sql-server-t-sql\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/zappysys.com\/blog\/import-amazon-mws-data-sql-server-t-sql\/#primaryimage","url":"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2016\/10\/amazon-mws-api-integration.png","contentUrl":"https:\/\/zappysys.com\/blog\/wp-content\/uploads\/2016\/10\/amazon-mws-api-integration.png","width":505,"height":505},{"@type":"BreadcrumbList","@id":"https:\/\/zappysys.com\/blog\/import-amazon-mws-data-sql-server-t-sql\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/zappysys.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to import Amazon MWS data into SQL Server (T-SQL)"}]},{"@type":"WebSite","@id":"https:\/\/zappysys.com\/blog\/#website","url":"https:\/\/zappysys.com\/blog\/","name":"ZappySys Blog","description":"SSIS \/ ODBC Drivers \/ API Connectors for JSON, XML, Azure, Amazon AWS, Salesforce, MongoDB and more","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/zappysys.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/zappysys.com\/blog\/#\/schema\/person\/2756c237457fbc95d82cb38962f81f82","name":"ZappySys","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/zappysys.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/5c9be148088ba9b8af8e955c5f7c22b5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/5c9be148088ba9b8af8e955c5f7c22b5?s=96&d=mm&r=g","caption":"ZappySys"},"sameAs":["http:\/\/www.zappysys.com\/","https:\/\/www.facebook.com\/ZappySys\/","https:\/\/twitter.com\/https:\/\/twitter.com\/zappysys\/"],"url":"https:\/\/zappysys.com\/blog\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/zappysys.com\/blog\/wp-json\/wp\/v2\/posts\/6961"}],"collection":[{"href":"https:\/\/zappysys.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zappysys.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zappysys.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zappysys.com\/blog\/wp-json\/wp\/v2\/comments?post=6961"}],"version-history":[{"count":29,"href":"https:\/\/zappysys.com\/blog\/wp-json\/wp\/v2\/posts\/6961\/revisions"}],"predecessor-version":[{"id":11868,"href":"https:\/\/zappysys.com\/blog\/wp-json\/wp\/v2\/posts\/6961\/revisions\/11868"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/zappysys.com\/blog\/wp-json\/wp\/v2\/media\/1632"}],"wp:attachment":[{"href":"https:\/\/zappysys.com\/blog\/wp-json\/wp\/v2\/media?parent=6961"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zappysys.com\/blog\/wp-json\/wp\/v2\/categories?post=6961"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zappysys.com\/blog\/wp-json\/wp\/v2\/tags?post=6961"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}