{"id":1109,"date":"2010-06-07T16:04:00","date_gmt":"2010-06-07T08:04:00","guid":{"rendered":"http:\/\/vm-officeblogs.cloudapp.net\/2010\/06\/07\/running-a-sql-stored-procedure-from-excel-no-vba\/"},"modified":"2022-07-26T04:21:44","modified_gmt":"2022-07-26T11:21:44","slug":"running-a-sql-stored-procedure-from-excel-no-vba","status":"publish","type":"post","link":"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/2010\/06\/07\/running-a-sql-stored-procedure-from-excel-no-vba\/","title":{"rendered":"Running a SQL Stored Procedure from Excel (No VBA)"},"content":{"rendered":"

Today\u2019s author is Mike Alexander, an Excel MVP who shows us how to run a Stored Procedure to get data from a SQL server.\u00a0<\/span><\/p>\n

We all know we can use MS Query to get data from a SQL server. Typically though, we pull from a Table or a View. Well in some organizations, the IT department wants all interaction with the server to be done through Stored Procedure. This adds a level of risk management and makes the DBAs feel better.<\/span><\/p>\n

So today, I’ll show you how to easily make Excel run a Stored Procedure to get data. <\/span><\/p>\n

Step 1:<\/span><\/b> Data tab \u2013 > From Other Sources -> From SQL Server\u00a0<\/span><\/p>\n

Step 2:<\/span><\/b> Enter Credentials. Your server name can be an IP address\u00a0<\/span><\/p>\n

Step 3:<\/span><\/b> Choose any old table or view. Pick a small one because we’ll discard it later anyway. <\/span><\/p>\n

Step 4:<\/span><\/b> Excel will pop up the Import Data dialog box. Click Properties here (NOT THE OK BUTTON). <\/span><\/p>\n

Step 5:<\/span><\/b> Click on the Definition tab. There, change Command Type to SQL, and then enter your Stored Procedure name in the Command Text input.\u00a0<\/span><\/p>\n

Step 6:<\/span><\/b> Excel complains about something\u2026.blah\u2026blah\u2026blah. Click Yes \u2013 (as in yes I know what I’m doing).\u00a0<\/span><\/p>\n

Step 7:<\/span><\/b> Excel will activate the Import Data dialog box again. This time click OK to fire the Stored Procedure and return the results. <\/span><\/p>\n

Step 8: <\/span><\/b>Marvel at your results <\/span><\/p>\n

Notes:<\/span><\/b><\/p>\n

\u00b7\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><\/span>Excel will fire the Stored Procedure each time you “Refresh” <\/span><\/p>\n

\u00b7\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><\/span>If you have to pass a parameter, you can enter it in the command text like this:<\/span><\/p>\n

\u00b7\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><\/span>If you have to pass dynamic parameters you’ll have to turn to VBA. I’ll do a post on this later this week. <\/span><\/p>\n

\u00b7\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><\/span>I assume you can do this with ORACLE databases too. <\/span><\/p>\n

\u00b7\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><\/span>I’ve yet to test whether this will fire a Stored Procedure that doesn’t return data. In other words, Stored Procedures that perform Insert, Update or Delete actions. I assume that if you can, there is the possibility of updating SQL from Excel through a simple connection. Pretty cool.\u00a0<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"

In some organizations, the IT department wants all interaction with the server to be done through Stored Procedure. This adds a level of risk management and makes the DBAs feel better.<\/p>\n","protected":false},"author":64,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"ep_exclude_from_search":false,"_classifai_error":"","footnotes":""},"content-type":[4035],"product":[4047,4036],"audience":[4081,4101,4102],"tags":[],"coauthors":[4437],"class_list":["post-1109","post","type-post","status-publish","format-standard","hentry","content-type-tips-and-guides","product-excel","product-microsoft-365","audience-enterprise","audience-personal-and-family","audience-small-business"],"yoast_head":"\nRunning a SQL Stored Procedure from Excel (No VBA) | Microsoft 365 Blog<\/title>\n<meta name=\"description\" content=\"In some organizations, the IT department wants all interaction with the server to be done through Stored Procedure. This adds a level of risk management and makes the DBAs feel better.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/2010\/06\/07\/running-a-sql-stored-procedure-from-excel-no-vba\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Running a SQL Stored Procedure from Excel (No VBA) | Microsoft 365 Blog\" \/>\n<meta property=\"og:description\" content=\"In some organizations, the IT department wants all interaction with the server to be done through Stored Procedure. This adds a level of risk management and makes the DBAs feel better.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/2010\/06\/07\/running-a-sql-stored-procedure-from-excel-no-vba\/\" \/>\n<meta property=\"og:site_name\" content=\"Microsoft 365 Blog\" \/>\n<meta property=\"article:published_time\" content=\"2010-06-07T08:04:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-07-26T11:21:44+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/wp-content\/uploads\/sites\/2\/2022\/06\/cropped-microsoft_logo_element.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"512\" \/>\n\t<meta property=\"og:image:height\" content=\"512\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"The Microsoft 365 Marketing Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"The Microsoft 365 Marketing Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 min read\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/2010\/06\/07\/running-a-sql-stored-procedure-from-excel-no-vba\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/2010\/06\/07\/running-a-sql-stored-procedure-from-excel-no-vba\/\"},\"author\":[{\"@id\":\"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/author\/the-microsoft-365-marketing-team\/\",\"@type\":\"Person\",\"@name\":\"The Microsoft 365 Marketing Team\"}],\"headline\":\"Running a SQL Stored Procedure from Excel (No VBA)\",\"datePublished\":\"2010-06-07T08:04:00+00:00\",\"dateModified\":\"2022-07-26T11:21:44+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/2010\/06\/07\/running-a-sql-stored-procedure-from-excel-no-vba\/\"},\"wordCount\":350,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/#organization\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/2010\/06\/07\/running-a-sql-stored-procedure-from-excel-no-vba\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/2010\/06\/07\/running-a-sql-stored-procedure-from-excel-no-vba\/\",\"url\":\"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/2010\/06\/07\/running-a-sql-stored-procedure-from-excel-no-vba\/\",\"name\":\"Running a SQL Stored Procedure from Excel (No VBA) | Microsoft 365 Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/#website\"},\"datePublished\":\"2010-06-07T08:04:00+00:00\",\"dateModified\":\"2022-07-26T11:21:44+00:00\",\"description\":\"In some organizations, the IT department wants all interaction with the server to be done through Stored Procedure. This adds a level of risk management and makes the DBAs feel better.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/2010\/06\/07\/running-a-sql-stored-procedure-from-excel-no-vba\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/2010\/06\/07\/running-a-sql-stored-procedure-from-excel-no-vba\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/2010\/06\/07\/running-a-sql-stored-procedure-from-excel-no-vba\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Running a SQL Stored Procedure from Excel (No VBA)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/#website\",\"url\":\"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/\",\"name\":\"Microsoft 365 Blog\",\"description\":\"Microsoft 365 brings together Office 365, Windows 10, and Enterprise Mobility + Security. It delivers a complete, intelligent, and secure solution to empower people.\",\"publisher\":{\"@id\":\"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/#organization\",\"name\":\"Microsoft 365 Blog\",\"url\":\"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/wp-content\/uploads\/sites\/2\/2019\/08\/ms-logo-amp.png\",\"contentUrl\":\"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/wp-content\/uploads\/sites\/2\/2019\/08\/ms-logo-amp.png\",\"width\":279,\"height\":60,\"caption\":\"Microsoft 365 Blog\"},\"image\":{\"@id\":\"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Running a SQL Stored Procedure from Excel (No VBA) | Microsoft 365 Blog","description":"In some organizations, the IT department wants all interaction with the server to be done through Stored Procedure. This adds a level of risk management and makes the DBAs feel better.","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:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/2010\/06\/07\/running-a-sql-stored-procedure-from-excel-no-vba\/","og_locale":"en_US","og_type":"article","og_title":"Running a SQL Stored Procedure from Excel (No VBA) | Microsoft 365 Blog","og_description":"In some organizations, the IT department wants all interaction with the server to be done through Stored Procedure. This adds a level of risk management and makes the DBAs feel better.","og_url":"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/2010\/06\/07\/running-a-sql-stored-procedure-from-excel-no-vba\/","og_site_name":"Microsoft 365 Blog","article_published_time":"2010-06-07T08:04:00+00:00","article_modified_time":"2022-07-26T11:21:44+00:00","og_image":[{"width":512,"height":512,"url":"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/wp-content\/uploads\/sites\/2\/2022\/06\/cropped-microsoft_logo_element.webp","type":"image\/png"}],"author":"The Microsoft 365 Marketing Team","twitter_card":"summary_large_image","twitter_misc":{"Written by":"The Microsoft 365 Marketing Team","Est. reading time":"1 min read"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/2010\/06\/07\/running-a-sql-stored-procedure-from-excel-no-vba\/#article","isPartOf":{"@id":"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/2010\/06\/07\/running-a-sql-stored-procedure-from-excel-no-vba\/"},"author":[{"@id":"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/author\/the-microsoft-365-marketing-team\/","@type":"Person","@name":"The Microsoft 365 Marketing Team"}],"headline":"Running a SQL Stored Procedure from Excel (No VBA)","datePublished":"2010-06-07T08:04:00+00:00","dateModified":"2022-07-26T11:21:44+00:00","mainEntityOfPage":{"@id":"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/2010\/06\/07\/running-a-sql-stored-procedure-from-excel-no-vba\/"},"wordCount":350,"commentCount":0,"publisher":{"@id":"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/#organization"},"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/2010\/06\/07\/running-a-sql-stored-procedure-from-excel-no-vba\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/2010\/06\/07\/running-a-sql-stored-procedure-from-excel-no-vba\/","url":"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/2010\/06\/07\/running-a-sql-stored-procedure-from-excel-no-vba\/","name":"Running a SQL Stored Procedure from Excel (No VBA) | Microsoft 365 Blog","isPartOf":{"@id":"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/#website"},"datePublished":"2010-06-07T08:04:00+00:00","dateModified":"2022-07-26T11:21:44+00:00","description":"In some organizations, the IT department wants all interaction with the server to be done through Stored Procedure. This adds a level of risk management and makes the DBAs feel better.","breadcrumb":{"@id":"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/2010\/06\/07\/running-a-sql-stored-procedure-from-excel-no-vba\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/2010\/06\/07\/running-a-sql-stored-procedure-from-excel-no-vba\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/2010\/06\/07\/running-a-sql-stored-procedure-from-excel-no-vba\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/"},{"@type":"ListItem","position":2,"name":"Running a SQL Stored Procedure from Excel (No VBA)"}]},{"@type":"WebSite","@id":"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/#website","url":"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/","name":"Microsoft 365 Blog","description":"Microsoft 365 brings together Office 365, Windows 10, and Enterprise Mobility + Security. It delivers a complete, intelligent, and secure solution to empower people.","publisher":{"@id":"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/#organization","name":"Microsoft 365 Blog","url":"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/wp-content\/uploads\/sites\/2\/2019\/08\/ms-logo-amp.png","contentUrl":"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/wp-content\/uploads\/sites\/2\/2019\/08\/ms-logo-amp.png","width":279,"height":60,"caption":"Microsoft 365 Blog"},"image":{"@id":"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/#\/schema\/logo\/image\/"}}]}},"distributor_meta":false,"distributor_terms":false,"distributor_media":false,"distributor_original_site_name":"Microsoft 365 Blog","distributor_original_site_url":"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog","push-errors":false,"_links":{"self":[{"href":"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/wp-json\/wp\/v2\/posts\/1109"}],"collection":[{"href":"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/wp-json\/wp\/v2\/users\/64"}],"replies":[{"embeddable":true,"href":"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/wp-json\/wp\/v2\/comments?post=1109"}],"version-history":[{"count":0,"href":"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/wp-json\/wp\/v2\/posts\/1109\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/wp-json\/wp\/v2\/media?parent=1109"}],"wp:term":[{"taxonomy":"content-type","embeddable":true,"href":"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/wp-json\/wp\/v2\/content-type?post=1109"},{"taxonomy":"product","embeddable":true,"href":"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/wp-json\/wp\/v2\/product?post=1109"},{"taxonomy":"audience","embeddable":true,"href":"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/wp-json\/wp\/v2\/audience?post=1109"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/wp-json\/wp\/v2\/tags?post=1109"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.microsoft.com\/en-us\/microsoft-365\/blog\/wp-json\/wp\/v2\/coauthors?post=1109"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}