{"id":892,"date":"2014-09-25T00:16:35","date_gmt":"2014-09-25T00:16:35","guid":{"rendered":"http:\/\/elbsolutions.com\/projects\/?p=892"},"modified":"2022-02-03T11:25:00","modified_gmt":"2022-02-03T17:25:00","slug":"sql-connections-drivers-odbc-drive-crazy-one-worked-import-excel-sql-server","status":"publish","type":"post","link":"https:\/\/elbsolutions.com\/projects\/sql-connections-drivers-odbc-drive-crazy-one-worked-import-excel-sql-server\/","title":{"rendered":"SQL Connections, Drivers and ODBC drive me crazy. Here is one that worked. Import to Excel from SQL Server"},"content":{"rendered":"<p>What I am rying to do is use a stored proc in SQL Server and feed it some parameters making it dynamic. What the stored proc does is a query to an excel spreadsheet and compares whats different in a SQL database. The crazy part was that<\/p>\n<ul>\n<li>using ADODB in VBA worked once under certain conditions,<\/li>\n<li>MSQuery works in others and &#8230;<\/li>\n<li>doing it with eh Import Data Wizard from the Data tab for SQL Server did NOT work &#8211; which is the one you would expect WOULD work best (the native one)<\/li>\n<\/ul>\n<p>So &#8211; I noticed that MSQuery worked<!--more--> &#8211; and frankly I don&#8217;t care what method &#8211; I need answers &#8211; not slick solutions for other people in this case &#8211; this is me doing engineering to get an answer\u00a0and not making a solution for someone else. Anyway, what I did is recorded all the scenarios after they worked. \u00a0What did not work is doing it all by hand in VBA but this was to a different server using a trusted connection &#8211; the old way that did work in VBA was done with a username\/password combo.<\/p>\n<p>MS Query to the rescue. Here is the fellow that inspired me to try this. THen once I had it all working, I understood and edited the VB.<\/p>\n<p>Some tips\/learning along the ways was<\/p>\n<ul>\n<li>a) you record making a QueryTable &#8211; not a ListTable BUT to reuse the QueryTable , look through the ListTables collection and use the myListTable.QueryTable item (a very tight connection between the two.<\/li>\n<li>b) follow this article to make a basic table query to ANY table\n<ul>\n<li><a href=\"http:\/\/exceluser.com\/formulas\/msquery-excel-relational-data.htm\" target=\"_blank\" rel=\"noopener noreferrer\">MSQuery as a relational tool on Excel Tables<\/a><\/li>\n<li><a href=\"http:\/\/stackoverflow.com\/questions\/4926441\/query-tables-querytables-in-excel-2010-with-vba-with-vba-creating-many-connect\" target=\"_blank\" rel=\"noopener noreferrer\">Refreshing SQL Server Queries<\/a>\u00a0(use this 2nd)<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>What I am rying to do is use a stored proc in SQL Server and feed it some parameters making it dynamic. What the stored proc does is a query to an excel spreadsheet and compares whats different in a SQL database. The crazy part was that using ADODB in VBA worked once under certain [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-892","post","type-post","status-publish","format-standard","hentry","category-general"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>SQL Connections, Drivers and ODBC drive me crazy. Here is one that worked. Import to Excel from SQL Server - ELB Solutions.com Inc.<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/elbsolutions.com\/projects\/sql-connections-drivers-odbc-drive-crazy-one-worked-import-excel-sql-server\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SQL Connections, Drivers and ODBC drive me crazy. Here is one that worked. Import to Excel from SQL Server - ELB Solutions.com Inc.\" \/>\n<meta property=\"og:description\" content=\"What I am rying to do is use a stored proc in SQL Server and feed it some parameters making it dynamic. What the stored proc does is a query to an excel spreadsheet and compares whats different in a SQL database. The crazy part was that using ADODB in VBA worked once under certain [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/elbsolutions.com\/projects\/sql-connections-drivers-odbc-drive-crazy-one-worked-import-excel-sql-server\/\" \/>\n<meta property=\"og:site_name\" content=\"ELB Solutions.com Inc.\" \/>\n<meta property=\"article:published_time\" content=\"2014-09-25T00:16:35+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-02-03T17:25:00+00:00\" \/>\n<meta name=\"author\" content=\"Etienne Bley\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Etienne Bley\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/sql-connections-drivers-odbc-drive-crazy-one-worked-import-excel-sql-server\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/sql-connections-drivers-odbc-drive-crazy-one-worked-import-excel-sql-server\\\/\"},\"author\":{\"name\":\"Etienne Bley\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/#\\\/schema\\\/person\\\/51e717c68f4f5917c63baf88f0896c39\"},\"headline\":\"SQL Connections, Drivers and ODBC drive me crazy. Here is one that worked. Import to Excel from SQL Server\",\"datePublished\":\"2014-09-25T00:16:35+00:00\",\"dateModified\":\"2022-02-03T17:25:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/sql-connections-drivers-odbc-drive-crazy-one-worked-import-excel-sql-server\\\/\"},\"wordCount\":306,\"articleSection\":[\"General\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/sql-connections-drivers-odbc-drive-crazy-one-worked-import-excel-sql-server\\\/\",\"url\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/sql-connections-drivers-odbc-drive-crazy-one-worked-import-excel-sql-server\\\/\",\"name\":\"SQL Connections, Drivers and ODBC drive me crazy. Here is one that worked. Import to Excel from SQL Server - ELB Solutions.com Inc.\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/#website\"},\"datePublished\":\"2014-09-25T00:16:35+00:00\",\"dateModified\":\"2022-02-03T17:25:00+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/#\\\/schema\\\/person\\\/51e717c68f4f5917c63baf88f0896c39\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/sql-connections-drivers-odbc-drive-crazy-one-worked-import-excel-sql-server\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/sql-connections-drivers-odbc-drive-crazy-one-worked-import-excel-sql-server\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/sql-connections-drivers-odbc-drive-crazy-one-worked-import-excel-sql-server\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SQL Connections, Drivers and ODBC drive me crazy. Here is one that worked. Import to Excel from SQL Server\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/#website\",\"url\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/\",\"name\":\"ELB Solutions.com Inc.\",\"description\":\"Bringing all your IT Pieces together\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/#\\\/schema\\\/person\\\/51e717c68f4f5917c63baf88f0896c39\",\"name\":\"Etienne Bley\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g\",\"caption\":\"Etienne Bley\"},\"url\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/author\\\/etienne-bley\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"SQL Connections, Drivers and ODBC drive me crazy. Here is one that worked. Import to Excel from SQL Server - ELB Solutions.com Inc.","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:\/\/elbsolutions.com\/projects\/sql-connections-drivers-odbc-drive-crazy-one-worked-import-excel-sql-server\/","og_locale":"en_US","og_type":"article","og_title":"SQL Connections, Drivers and ODBC drive me crazy. Here is one that worked. Import to Excel from SQL Server - ELB Solutions.com Inc.","og_description":"What I am rying to do is use a stored proc in SQL Server and feed it some parameters making it dynamic. What the stored proc does is a query to an excel spreadsheet and compares whats different in a SQL database. The crazy part was that using ADODB in VBA worked once under certain [&hellip;]","og_url":"https:\/\/elbsolutions.com\/projects\/sql-connections-drivers-odbc-drive-crazy-one-worked-import-excel-sql-server\/","og_site_name":"ELB Solutions.com Inc.","article_published_time":"2014-09-25T00:16:35+00:00","article_modified_time":"2022-02-03T17:25:00+00:00","author":"Etienne Bley","twitter_misc":{"Written by":"Etienne Bley","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/elbsolutions.com\/projects\/sql-connections-drivers-odbc-drive-crazy-one-worked-import-excel-sql-server\/#article","isPartOf":{"@id":"https:\/\/elbsolutions.com\/projects\/sql-connections-drivers-odbc-drive-crazy-one-worked-import-excel-sql-server\/"},"author":{"name":"Etienne Bley","@id":"https:\/\/elbsolutions.com\/projects\/#\/schema\/person\/51e717c68f4f5917c63baf88f0896c39"},"headline":"SQL Connections, Drivers and ODBC drive me crazy. Here is one that worked. Import to Excel from SQL Server","datePublished":"2014-09-25T00:16:35+00:00","dateModified":"2022-02-03T17:25:00+00:00","mainEntityOfPage":{"@id":"https:\/\/elbsolutions.com\/projects\/sql-connections-drivers-odbc-drive-crazy-one-worked-import-excel-sql-server\/"},"wordCount":306,"articleSection":["General"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/elbsolutions.com\/projects\/sql-connections-drivers-odbc-drive-crazy-one-worked-import-excel-sql-server\/","url":"https:\/\/elbsolutions.com\/projects\/sql-connections-drivers-odbc-drive-crazy-one-worked-import-excel-sql-server\/","name":"SQL Connections, Drivers and ODBC drive me crazy. Here is one that worked. Import to Excel from SQL Server - ELB Solutions.com Inc.","isPartOf":{"@id":"https:\/\/elbsolutions.com\/projects\/#website"},"datePublished":"2014-09-25T00:16:35+00:00","dateModified":"2022-02-03T17:25:00+00:00","author":{"@id":"https:\/\/elbsolutions.com\/projects\/#\/schema\/person\/51e717c68f4f5917c63baf88f0896c39"},"breadcrumb":{"@id":"https:\/\/elbsolutions.com\/projects\/sql-connections-drivers-odbc-drive-crazy-one-worked-import-excel-sql-server\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/elbsolutions.com\/projects\/sql-connections-drivers-odbc-drive-crazy-one-worked-import-excel-sql-server\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/elbsolutions.com\/projects\/sql-connections-drivers-odbc-drive-crazy-one-worked-import-excel-sql-server\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/elbsolutions.com\/projects\/"},{"@type":"ListItem","position":2,"name":"SQL Connections, Drivers and ODBC drive me crazy. Here is one that worked. Import to Excel from SQL Server"}]},{"@type":"WebSite","@id":"https:\/\/elbsolutions.com\/projects\/#website","url":"https:\/\/elbsolutions.com\/projects\/","name":"ELB Solutions.com Inc.","description":"Bringing all your IT Pieces together","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/elbsolutions.com\/projects\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/elbsolutions.com\/projects\/#\/schema\/person\/51e717c68f4f5917c63baf88f0896c39","name":"Etienne Bley","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g","caption":"Etienne Bley"},"url":"https:\/\/elbsolutions.com\/projects\/author\/etienne-bley\/"}]}},"_links":{"self":[{"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/posts\/892","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/comments?post=892"}],"version-history":[{"count":2,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/posts\/892\/revisions"}],"predecessor-version":[{"id":2783,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/posts\/892\/revisions\/2783"}],"wp:attachment":[{"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/media?parent=892"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/categories?post=892"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/tags?post=892"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}