title: Call a Stored Procedure which has errors, continue and get full output
body: <p>I want to call a SQL-Server SP (<a href="https://ola.hallengren.com/sql-server-integrity-check.html" rel="nofollow noreferrer">Integrity Check- Ola Hallengren</a>) from a C# application.</p>
  <p>In cases of any corruption found in any database (multiple) errors are thrown.</p>
  <p>Executed within SSMS the <code>PRINT</code> output inlcudes a very informative cummulative output (log entries mixed with error messages). The execution continues after each error obviously. In SSMS you can use <em>output to file</em> to get a file with this content.</p>
  <p>From C# I tried to use <code>cmd.ExecuteNonQuery()</code>, which works, but it breaks on the first error.</p>
  <p>Is there any way to call a SP from C# without breaking on errors with the goal to get the full output at the end?</p>
  <h2>EDIT:</h2>
  <p>To test this, I found a <em>prepared</em> corrupt db to download (<a href="https://www.sqlskills.com/sql-server-resources/sql-server-demos/" rel="nofollow noreferrer">look here</a>)</p>
  <p>Try this</p>
  <pre><code>CREATE PROCEDURE dbo.test
  AS
  BEGIN
      PRINT 'a clean db'
      DBCC CHECKDB (someDb) WITH NO_INFOMSGS;
      PRINT 'a bad db'
      DBCC CHECKDB (SomeCorruptDB) WITH NO_INFOMSGS
      PRINT 'one more clean db'
      DBCC CHECKDB (AotherGoodDB) WITH NO_INFOMSGS
  END 
  GO
  EXEC dbo.test;
  GO
  DROP PROCEDURE dbo.test;
  GO
  </code></pre>
  <p>the error messages come <em>from within <code>DBCC CHECKDB</code></em>. The SP is executed down to the final line.</p>
  <h2>UPDATE</h2>
  <p>Hello all helpfull people!<br />
  Thx for looking into this. Further tests brought up, that the SQL-Exception thrown within C# has got all information packed inside. I was blinded by the obvious first catch.
  Diving into it, I found, that my SP was executed to the end actually. The <code>SqlException</code> has got an <code>.Errors</code> property which reflects all errors found.
  Much work left to do, but problem solved.
  Thx for your help!</p>