nvarchar column length...

  • For the below table create script, the column length is specified as 255, for a nvarchar column, when

    create table TestA

    (

    ID int,

    IdDes nvarchar(255)

    )

    After table is created, lengths are

    ID int no 4

    IdDes nvarchar no 510

    After the table is created, the lenght of the IdDes column is 510 instead of 255.

    Intrestingly, any length specified in the column defintion, is doubled after table creation.

    What seems to be happening. Any ideas.

  • You're seeing the length in bytes. Each NVARCHAR character takes up two bytes of storage.

  • notoriousdba (9/8/2011)


    You're seeing the length in bytes. Each NVARCHAR character takes up two bytes of storage.

    In SQL Server, do you know of a language or collation setting that would cause any NVARCHAR character to use only 1 byte?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.
    "Change is inevitable... change for the better is not".

    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)
    Intro to Tally Tables and Functions

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

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