Search code examples
sql-serverfunctiontextvarcharsqldatatypes

In SQL Server, how do I create a function that returns a text longer than 8,000 characters?


I need to create a function in SQL Server that returns a string. In some cases, this string is longer than 8,000 characters, which is the maximum value for a varchar data type. text, and ntext data types are not supported when writing functions in SQL Server 2008.

So any idea of an alternative that I could implement ?

Thank You

(The code used for creating the function is very long, so I didn't included it)


Solution

  • You should be able to use a VARCHAR(MAX) as the return type of the function.