title: Return a comma separated list of strings from a stored procedure
body: <p>I am trying to return a comma separated list of strings from a stored procedure like this:</p>
  
  <pre><code>@Strings NVARCHAR(MAX) OUT
  
  ...
  
  DECLARE @Sql NVARCHAR(MAX);
  
  SET @Sql = 'SELECT @Strings = COALESCE(@Strings + '', '','''') + CAST(Name AS NVARCHAR(MAX)) FROM ' + @BlaTableName + ' order by Name'
  
  EXEC sp_executesql @Sql
  </code></pre>
  
  <p>but I get:</p>
  
  <blockquote>
    <p>Must declare the scalar variable "@Strings"</p>
  </blockquote>
  
  <p>Any ideas?</p>