<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to execute a MS SQL Server Stored Procedure? in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-execute-a-MS-SQL-Server-Stored-Procedure/m-p/35547#M4461</link>
    <description>I have a stored procedure that creates a table. I want eg to execute the stored procedure so i can link the database table into eg.&lt;BR /&gt;
&lt;BR /&gt;
How does one execute a stored procedure from EG?</description>
    <pubDate>Tue, 29 Dec 2009 20:57:54 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2009-12-29T20:57:54Z</dc:date>
    <item>
      <title>How to execute a MS SQL Server Stored Procedure?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-execute-a-MS-SQL-Server-Stored-Procedure/m-p/35547#M4461</link>
      <description>I have a stored procedure that creates a table. I want eg to execute the stored procedure so i can link the database table into eg.&lt;BR /&gt;
&lt;BR /&gt;
How does one execute a stored procedure from EG?</description>
      <pubDate>Tue, 29 Dec 2009 20:57:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-execute-a-MS-SQL-Server-Stored-Procedure/m-p/35547#M4461</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-12-29T20:57:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to execute a MS SQL Server Stored Procedure?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-execute-a-MS-SQL-Server-Stored-Procedure/m-p/35548#M4462</link>
      <description>I am still learning both SQL and re-aquainting myself with SAS via SAS EG/LE.  I haven't had time to actually run this code but here is what my research seems to indicate.&lt;BR /&gt;
&lt;BR /&gt;
I just got done looking at the "PROC SQL essentials code samples" available here on the website.  It appears you mostly use the exact same code you would in an SQL editor window to execute the stored procedure.&lt;BR /&gt;
&lt;BR /&gt;
Below is a sample of executing some SQL against an Oracle database that is located on the same pc as Enterprise Guide.  Below that is guess at an example of code for a stored procedure and executing it in Ms SQL.&lt;BR /&gt;
&lt;BR /&gt;
PROC SQL;&lt;BR /&gt;
LIBNAME bluesky "C:\mydata\bluesky bookstore\";&lt;BR /&gt;
&lt;BR /&gt;
CONNECT TO ORACLE&lt;BR /&gt;
(user=scott password=tiger path=master);&lt;BR /&gt;
&lt;BR /&gt;
SELECT 	* &lt;BR /&gt;
FROM	CONNECTION TO ORACLE&lt;BR /&gt;
&lt;BR /&gt;
(SELECT   currency "Currency", avg(exchrate) "Average",&lt;BR /&gt;
          max(exchrate) "Maximum", min(exchrate) "Minimum"&lt;BR /&gt;
FROM      bluesky.currency&lt;BR /&gt;
WHERE     currency IN ('CAD','GBP','DEM')&lt;BR /&gt;
GROUP BY  currency&lt;BR /&gt;
);&lt;BR /&gt;
&lt;BR /&gt;
DISCONNECT FROM ORACLE;&lt;BR /&gt;
&lt;BR /&gt;
QUIT;&lt;BR /&gt;
------------------------------snip-----------------------------------------------------&lt;BR /&gt;
Here's the MSQL sample code I found outside of SAS.com code:&lt;BR /&gt;
&lt;BR /&gt;
    CREATE PROCEDURE sp_GetInventory&lt;BR /&gt;
    @location varchar(10)&lt;BR /&gt;
    AS&lt;BR /&gt;
    SELECT Product, Quantity&lt;BR /&gt;
    FROM Inventory&lt;BR /&gt;
    WHERE Warehouse = @location&lt;BR /&gt;
&lt;BR /&gt;
Our Florida warehouse manager can then access inventory levels by issuing the command&lt;BR /&gt;
&lt;BR /&gt;
    EXECUTE sp_GetInventory 'FL'&lt;BR /&gt;
&lt;BR /&gt;
The New York warehouse manager can use the same stored procedure to access that area's inventory.&lt;BR /&gt;
&lt;BR /&gt;
    EXECUTE sp_GetInventory 'NY'&lt;BR /&gt;
---------------------------------------snip--------------------------------------------------------&lt;BR /&gt;
&lt;BR /&gt;
So the code that you want appears to be:&lt;BR /&gt;
&lt;BR /&gt;
PROC SQL;&lt;BR /&gt;
LIBNAME bluesky "C:\mydata\bluesky bookstore\";  &amp;lt;- local database location I think&lt;BR /&gt;
&lt;BR /&gt;
CONNECT TO MSQL   &amp;lt;- this might not be the correct name for ms sql connector&lt;BR /&gt;
(user=scott password=tiger path=master);&lt;BR /&gt;
&lt;BR /&gt;
    EXECUTE sp_GetInventory 'FL'  &amp;lt;- whatever you called the stored procedure plus any parms you need to pass in.&lt;BR /&gt;
&lt;BR /&gt;
DISCONNECT FROM MSQL;&lt;BR /&gt;
&lt;BR /&gt;
QUIT;&lt;BR /&gt;
&lt;BR /&gt;
-------------------------------------------snip-----------------------------------------------&lt;BR /&gt;
&lt;BR /&gt;
Try it out, generate some errors and come back and tell us about them &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
&lt;BR /&gt;
Tom Miller</description>
      <pubDate>Wed, 30 Dec 2009 00:20:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-execute-a-MS-SQL-Server-Stored-Procedure/m-p/35548#M4462</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-12-30T00:20:28Z</dc:date>
    </item>
  </channel>
</rss>

