title: Convert to varchar max inside string_agg function
body: <p>I have a function a STRING_AGG function which is throwing error</p>
  <blockquote>
  <p>Error message: STRING_AGG aggregation result exceeded the limit of
  8000 bytes. Use LOB types to avoid result truncation.</p>
  </blockquote>
  <p>As this <a href="https://www.mssqltips.com/sqlservertutorial/9371/sql-string-agg-function/#:%7E:text=Error%20message%3A%20STRING_AGG%20aggregation%20result,varchar(max)%20as%20follows." rel="nofollow noreferrer">Documentation</a>, says I need to convert to <code>varchar(max)</code></p>
  <p>Current:</p>
  <pre><code> STRING_AGG(CONCAT([CT].[DeviceType] , ': ' , [COM].[Address]) , ', ')) AS [Contact]
  </code></pre>
  <p>Try:</p>
  <pre><code>STRING_AGG(CONVERT(VARCHAR(MAX),(CONCAT([CT].[DeviceType] , ': ' , [COM].[Address])) , ', ')) AS [Contact]
  </code></pre>
  <p>But it is throwing error:</p>
  <blockquote>
  <p>The STRING_AGG function requires 2 argument(s).</p>
  </blockquote>
  <p>What am I doing wrong? Regards</p>