title: Use result of stored procedure inline in SELECT statement
body: <p>I would like to execute a stored procedure inline, in the column definition of a <code>SELECT</code> statement, something similar to this:</p>
  
  <pre><code>SELECT n.Name,
         n.Key,
         (EXEC sp_GetNickname @nameKey = n.NameKey) AS Nickname
  FROM Names n
  </code></pre>
  
  <p>I do not have access to modify the stored procedure (it comes from a third party system), but I know for a fact that it always selects only one row and one column (it's a scalar result).</p>
  
  <p>I need to be able to call it inline because this select statement is inside a recursive CTE, something like this:</p>
  
  <pre><code>WITH Nicknames (Name, Key)
  AS
  (
      SELECT ... -- Base
      UNION ALL
      SELECT ... -- Recursive
  )
  </code></pre>
  
  <p>There is also an "OUT" version of the stored procedure if that would be more useful, it would be executed as such:</p>
  
  <pre><code>EXEC sp_GetNicknameOut @nameKey = n.NameKey,
                         @outNickname = @theNickname OUTPUT
  </code></pre>
  
  <p>I can't add any stored procedures or functions to the database because this query is being executed from a C# application on the fly.</p>
  
  <p>How can I achieve this?</p>