title: How to get *everything* back from a stored procedure using JDBC
body: <p>I occasionally encounter two forms of strange behaviour when using JDBC to work with SQL Server stored procedures:</p>
  
  <p><strong>Issue 1:</strong> I run a stored procedure in SQL Server Management Studio (SSMS) and it returns a result set. However, when I try</p>
  
  <pre class="lang-java prettyprint-override"><code>try (CallableStatement cs = conn.prepareCall("{call dbo.TroublesomeSP}")) {
      ResultSet rs = cs.executeQuery();
  </code></pre>
  
  <p>I get the exception</p>
  
  <blockquote>
    <p>com.microsoft.sqlserver.jdbc.SQLServerException: The statement did not return a result set.</p>
  </blockquote>
  
  <p><strong>Issue 2:</strong> I run a stored procedure in SSMS and it raises an error, but when I use JDBC to <code>.execute</code> the stored procedure no exception is thrown.</p>
  
  <p>Why do these issues occur and how can I avoid them?</p>