title: "Invalid SQL statement" error when trying to execute SQL Server stored procedure from Access
body: <p>I'm operating on a virtual machine where my SQL server and MS Access sit. I set up an ODBC connection from Access to SQL and linked a few tables. I can perform the usual operations on these tables (select/update etc.).</p>
  
  <p>BUT, I'm unable to run a stored procedure for some weird reason! The procedure runs perfectly on SSMS but not when I call it from Access VBA. Following is the code I'm using to execute the proc (I need to pass 3 parameters as well, but I've excluded that from the code below for simplicity):</p>
  
  <pre><code>With CurrentDb.QueryDefs("qPass")
    .SQL = "exec [HS].[spGetXMLExtract]"
    .Execute
  End With
  </code></pre>
  
  <p>The error returned by MS Access is </p>
  
  <blockquote>
    <p>Invalid SQL statement: expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'.</p>
  </blockquote>
  
  <p>Don't know if this is happening because:
  1. I've got these applications on a VM; and/or
  2. I need to somehow link the stored procedure to MS Access just like I did for the tables (perhaps this can't be done).</p>
  
  <p>I guess there are convoluted methods I 'might' be able to adopt but I don't want to. Example:</p>
  
  <p><strong>1.</strong> Create a table in SQL with columns that store the parameters; Write an <code>AFTER UPDATE</code> Trigger on that table which executes my stored procedure; Fire an 'Update' query from MS Access that would update the parameters in that table and a SQL trigger then gets fired. OR;</p>
  
  <p><strong>2.</strong> Eliminate the stored procedure from the equation completely and execute it's individual statements (select/update/insert etc.) through a Sub in MS Access. Don't know if this would cause problems with creating temp tables though.</p>
  
  <p>Can someone please advise on this, this is a real blocker!</p>
  
  <p>Thanks in advance!</p>