I'm running a Website using classic ASP and SQL Server 2012, on IIS 7.5. The website is data-driven, and I'm using stored procedures to create strings of HTML text to present the Web page. But the strings passed back from the stored procedures are being truncated to 4000 characters. How do I keep truncation from happening?
Details: my stored procedure is defined as:
CREATE PROCEDURE [dbo].[spCourseButtonsDisplay]
@str NVARCHAR(MAX) OUTPUT
The string concatenation in the stored procedure uses a cast
(I read somewhere that this would guard against truncation):
SET @str = CAST(@str + ... AS nvarchar(MAX));
Finally, I return with:
RETURN len(@str)
Note that I can execute the stored procedure in SQL Server Management Studio and get strings longer than 4000 (I've tested with >12000). But not so in asp.
I define the stored procedure parameters in my asp code:
.Parameters.Append .CreateParameter("StrLen", 3, 4) 'adInteger, adParamReturnValue
.Parameters.Append .CreateParameter("Str", 202, 2, 2147483646) 'adVarWChar, adParamOutput
The 2147483646 is one less than MAX, but is the largest number I can put without an error.
But when I execute the stored procedure from asp and output these 3 values:
Response.Write(CStr(objSP.Parameters("StrLen")) + "<br/>")
Response.Write(CStr(Len(objSP.Parameters("Str"))) + "<br/>")
Response.Write(objSP.Parameters("Str"))
I get the actual length the stored procedure created (>4000), 4000, and a truncated string.
How can I get the whole string?