Friday, 4 April 2014

Lesson learnt on nvarchar v.s SqlString

I had gone through an issue that related to nvarchar(max) data type. During resolving the issue, I had learnt below:

  1. The maximum length we can specify in an nvarchar type is nvarchar(4000) whereas the maximum for varchar is varchar(8000)
  2. As for nvarchar(max) the maximum data it can hold is 2GB chars.
  3. In C# for managed stored procedure, if to specify nvarchar(max), we need to declare the SqlString as [SqlFacet(MaxSize = -1)]SqlString. If only use SqlString, it will automatically default to nvarchar(4000) instead.
It was tricky to figure this out but the resolution on the issue has benefited me to learn more.

No comments: