How Can Max Field width of NVARCHAR be 11611 ??

  • I thought that NVARCHAR(MAX) was limited to a 4000 character limit, and VARCHAR(MAX) was 8000.

    This table contains errors from multiple sources.

    CREATE TABLE dbo.ErrorLog(
                    Id                       BIGINT IDENTITY(1, 1)    NOT NULL,
                    DateTimeUtc     DATETIME2(7)                  NOT NULL,
                    ServiceId           UNIQUEIDENTIFIER       NOT NULL,
                    IncidentId          UNIQUEIDENTIFIER        NULL,
                    [Message]         NVARCHAR(MAX)            NULL,
                    EventType         NVARCHAR(16)                NOT NULL,
    PRIMARY KEY CLUSTERED(Id)
                    WITH(PAD_INDEX=OFF, STATISTICS_NORECOMPUTE=OFF, IGNORE_DUP_KEY=OFF, ALLOW_ROW_LOCKS=ON, ALLOW_PAGE_LOCKS=ON)ON [PRIMARY]
    )ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
    GO

    SELECT
                    MaxWidth_Message      = MAX(LEN([Message]))
    FROM dbo.ErrorLog

    And the results are [MaxWidth_Message] = 11611

    Corporate Policy Prevents me from entering the entire Error, but they are stack trace errors that start with something like this;

    "System.AggregateException: One or more errors occurred. ---> System.ServiceModel.FaultException`1[System.ServiceModel.ExceptionDetail]: The specified initialization vector (IV) does not match the block size for this algorithm.
    Parameter name: iv
       at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter)
       at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
       at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
       at System.ServiceModel.Channels.ServiceChannelProxy.TaskCreator.<>c__DisplayClass6_0.<CreateTask>b__0(IAsyncResult asyncResult)
       at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
       at xxxxx.xxxxx.xxxxx.xxxxx.LoadService.LoadServiceClient.<InvokeChannelTask>d__10`1.MoveNext() in E:\..\..\..\..\..\LoadServiceClient.cs:line 108
    ……………………………………

    There are many groups line lines like the last 5 all ending with a different last line     :line ###

    Has anyone run into anything like this before ?
    Thanks.

  • when you use the "max" setting, the max size is 2GB.

    From BOL:

    nvarchar [ ( n | max ) ]
    Variable-length Unicode string data. n defines the string length and can be a value from 1 through 4,000. max indicates that the maximum storage size is 2^30-1 characters. 

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?

  • Budd - Thursday, July 12, 2018 2:15 PM

    I thought that NVARCHAR(MAX) was limited to a 4000 character limit, and VARCHAR(MAX) was 8000.

    If this were true, there would be no need for MAX at all – people would just use 
    NVARCHAR(4000) and VARCHAR(8000).

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

  • Thank you.  It's like a light bulb just went ON...
    I do remember that now and when I read it it made no sense, but all of a sudden now.  "LIGHT BULB"

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply