Data type differences. . .nvarchar vs varchar, etc.

  • I was wondering if someone could explain the differences between the nvarchar v. varchar, ntext v. text, and nchar v. char. I understand it from the perspective of the inclusion of the unicode values. My question is how do I decide which type to use as I am designing a database. In other words, what type of questions should I be asking.

    Thanks!

  • Basically will you need to handle any extended character lanuages such as chinese or have special characters that don't esit in the default set?

  • Do you foresee a need to use character sets from other languages, Kanji, Cyrilic, what have you? No, use VARCHAR. Yes, use NVARCHAR.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Thanks for your short but helpful replies.

  • Don't forget about Unicode and non-Unicode. If you plan on interfacing with a mainframe (AS400 for example) you might want to consider NVARCHAR; especially if you plan on using SSIS to move data between the boxes.

    SSIS does not automatically convert between the 2 code sets so you will need to and it can be a pain to constantly have to convert back and forth.

    -Mike

  • Replies so far seem to have missed the obvious point that the same text takes up twice as much space in the database as nvarchar - because the unicode character set uses 2 bytes per character. So unless you need funny characters it is better to use varchar. This is not just because of database space - obviously all data being pulled back to the client is doubled up too - so 100 chars of varchar = about 100 bytes but it would be 200 bytes for nvarchar doubling network loads.

  • Thanks, James. It looks like I don't need the nvarchar data type for my simple database. I appreciate everyone's response.

  • Books On Line?

Viewing 8 posts - 1 through 7 (of 7 total)

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