title: The selected stored procedure or function returns no columns
body: <p>I've searched in the internet and found similar posts about it. However, no solution worked for me.</p>
  
  <p>I'm facing an issue with one of my stored procedures. When adding it to my project in Visual Studio I get the following message:</p>
  
  <blockquote>
    <p>The selected stored procedure or function returns no columns.</p>
  </blockquote>
  
  <p>Earlier I could solve the problem by adding <code>SET FMTONLY OFF</code> in my procedure (as answered <a href="https://stackoverflow.com/questions/7128747/ef4-the-selected-stored-procedure-returns-no-columns">here</a>). Now this doesn't change anything; it still returns no columns according to EF.</p>
  
  <p>My stored procedure looks like this:</p>
  
  <pre><code>ALTER PROCEDURE [dbo].[spImportData]
      @someParameter
  AS
  BEGIN
      SET NOCOUNT ON;
  
      -- Some insertion
      INSERT INTO dbo.SomeTable ([SomeField])
      SELECT @someParameter
  
      SELECT CAST(SCOPE_IDENTITY() AS BIGINT) AS ImportId
  END
  </code></pre>
  
  <p>Same result when using a temp table:</p>
  
  <pre><code>CREATE TABLE #temp (ImportId BIGINT)
  INSERT INTO #temp (ImportId)
  SELECT CAST(SCOPE_IDENTITY() AS BIGINT)
  SELECT ImportId FROM #temp
  DROP TABLE #temp
  </code></pre>
  
  <p>Still no columns with a table variable:</p>
  
  <pre><code>DECLARE @importId BIGINT = SELECT CAST(SCOPE_IDENTITY() AS BIGINT)
  SELECT @importId
  </code></pre>
  
  <p>When executing the procedure directly in SQL Server, I'm getting the desired value.</p>
  
  <p>What am I missing? I thought <code>SET FMTONLY OFF</code> would do the trick but in this case nothing changes and my procedure still "returns no columns".</p>
  
  <hr>
  
  <p><strong>Edit 1</strong></p>
  
  <p>I tried what @NEER suggested in his comment. I changed the <code>SELECT</code> to <code>SELECT 1 AS ImportId</code>. But I'm still getting the same message.</p>