Results 1 to 7 of 7
  1. #1
    Join Date
    Dec 2004
    Posts
    22

    Unanswered: quick easy question [Resolved]

    Whats the difference between nvarchar and varchar, and which one should I use?

    Thanks
    Last edited by oak12; 12-29-04 at 12:32.

  2. #2
    Join Date
    Feb 2004
    Posts
    492
    nvarchar is unicode (to support alternate charactersets), varchar is not.

  3. #3
    Join Date
    Dec 2004
    Posts
    22

    Thanks

    I looked at the help in SQL server and found that but didn't really understand, I don't plan to have any foreign Charecters in my database, but is there any reason not to use nvarchar just incase?

  4. #4
    Join Date
    Feb 2002
    Location
    Houston, TX
    Posts
    809

    quick and easy answer

    from SQL Server Books Online...

    char and varchar
    Fixed-length (char) or variable-length (varchar) character data types.

    nchar and nvarchar
    Character data types that are either fixed-length (nchar) or variable-length (nvarchar) Unicode data and use the UNICODE UCS-2 character set.


    If you need to store Unicode data use the nchar or nvarchar variation otherwise use char or varchar.
    Paul Young
    (Knowledge is power! Get some!)

  5. #5
    Join Date
    Dec 2004
    Posts
    22

    Thanks

    Thanks for you help will use Varchar then, hope you all had a merry Christmas.

  6. #6
    Join Date
    Feb 2002
    Location
    Houston, TX
    Posts
    809
    Quote Originally Posted by oak12
    I looked at the help in SQL server and found that but didn't really understand, I don't plan to have any foreign Charecters in my database, but is there any reason not to use nvarchar just incase?

    You reduce your storage space by half...

    with varchar(100) you can store 100 bytes of data with nvarchar(100) you can only store 50 bytes of data, the remaining space is used for unicode support.
    Paul Young
    (Knowledge is power! Get some!)

  7. #7
    Join Date
    Feb 2004
    Posts
    492
    In BOL the topic "Character Data" , the topic "Using Unicode Data" says:

    Use of nchar, nvarchar, and ntext is the same as char, varchar, and text, respectively, except that:

    - Unicode supports a wider range of characters.
    - More space is needed to store Unicode characters.
    - The maximum size of nchar and nvarchar columns is 4,000 characters, not 8,000 characters like char and varchar.
    - Unicode constants are specified with a leading N: N'A Unicode string'.

    So I guess it really depends on what the column is used for. If there's no need to support alternate charactersets, I'd go for varchar.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •