... until the collector arrives ...

This "blog" is really just a scratchpad of mine. There is not much of general interest here. Most of the content is scribbled down "live" as I discover things I want to remember. I rarely go back to correct mistakes in older entries. You have been warned :)

2011-12-17

jTDS vs NVARCHAR(MAX)

jTDS truncates VARCHAR and NVARCHAR stored procedure output parameter values that are longer than 4000 characters for NVARCHAR, 8000 for VARCHAR. This is a consequence of the fact that jTDS is still using the old SQL Server 2000 version of the TDS protocol. The jTDS developers are aware of this problem, but the comments in the bug report suggest that it may be a while before the problem is corrected. In the meantime, the work-around is to replace the output parameter with a single row, single column result set. If one is reluctant (or unable) to change the stored procedure, then the following sequence will work as well:

DECLARE @result NVARCHAR(MAX)
EXEC dbo.myproc(..., @result OUTPUT)
SELECT @result

Blog Archive