>nvarchar(max) should be enough. You may be falling into some trap here when you concatenate mulitple strings into one. Are you using PRINT to see the output? If so, it's limited to 8000 characters.
I think that could have been the reason. BTW, what is the value of max?