KentDBerry
asked on
Why is Concatenation of 2 nvarchar(max) values truncating?
I'm using a cursor to concatenate all the values of the OriginalComments column into one variable called @Comments. Both are declared as nvarchar(max). Why does the line where concatenation occurs result in an empty string?
Declare @Comments nvarchar(max)
Declare @Question nvarchar(max)
Declare @DisplayOrder nvarchar(max)
Declare @OriginalComments nvarchar(max)
OPEN Comments_Cursor
FETCH NEXT FROM Comments_Cursor INTO @Question, @DisplayOrder, @OriginalComments
WHILE @@FETCH_STATUS = 0
BEGIN
Select @Comments = rtrim(@Comments) + rtrim(@OriginalComments) + '; '
Print @OriginalComments
Print rtrim(@Comments)
FETCH NEXT FROM Comments_Cursor INTO @Question, @DisplayOrder, @OriginalComments
END
CLOSE Comments_Cursor
DEALLOCATE Comments_Cursor
Print @Comments
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER