T-sql Datatypes

  • hello,

    what is the difference between the

    NCHAR() AND NVARCHAR()

    Regards:

    Dastagiri.D

    Thanks
    Dastagiri.D

  • nchar

    Fixed-length Unicode character data of n characters. n must be a value from 1 through 4,000. The storage size is two times n bytes. The ISO synonyms for nchar are national char and national character.

    nvarchar

    Variable-length Unicode character data. n can be a value from 1 through 4,000. max indicates that the maximum storage size is 2^31-1 bytes. The storage size, in bytes, is two times the number of characters entered + 2 bytes. The data entered can be 0 characters in length. The ISO synonyms for nvarchar are national char varying and national character varying

  • nChar() is Fixed length

    and nVarChar is variable length.

    In practice, the disk space used is

    nChar(5) => will always use 12 Bytes ( 2 *n ) +2

    nVarChar(5) = > uses 3 ( ( 1*2)+2 Bytes ) up to 12 Bytes depending on number of characters entered and ansi-Padding settings.

    Check BOL nChar and nVarchar for more details

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

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