title: Why is SQLExecute returning SQL_NO_DATA when running a procedure with NOCOUNT ON?
body: <p>I have the following procedure, which I don't want SQL to show affected row counts:</p>
  
  <pre><code>CREATE PROCEDURE UP_STOREDPROC @field VARCHAR(15)
  AS
  SET NOCOUNT ON;
  INSERT INTO MYTABLE (field) VALUES (@field);
  GO
  </code></pre>
  
  <p>And a C project using unixODBC/FreeTDS to execute this proc after a prepared statement (<code>SQLPrepare</code>).</p>
  
  <p>After the preparation, when it executes the statement by calling <code>SQLExecute</code>, it always return <code>SQL_NO_DATA</code> (100).</p>
  
  <p>But, from <a href="https://msdn.microsoft.com/en-us/library/ms713584(v=vs.85).aspx" rel="nofollow">ODBC documentation</a>: </p>
  
  <blockquote>
    <p>If SQLExecute executes a <strong>searched update, insert, or delete</strong> statement
    that does not affect any rows at the data source, the call to
    SQLExecute returns SQL_NO_DATA.</p>
  </blockquote>
  
  <p>So, it's not a searched insert. If the first line of the procedure is changed to <code>SET NOCOUNT OFF</code> then everything works fine.</p>
  
  <p>What is wrong?</p>