locked
Is VarChar the correct choice if no unicode text is to be entered? RRS feed

  • Question

  • I want to enter non-unicode (english) characters in all the columns. I have been using nVarChar till I learned that it is to be used only when unicode text is to be entered.

    In this case, is VarChar the right choice? As opposed to VarChar, how nVarChar can affect performance of queries?

     

    Wednesday, January 11, 2012 10:27 AM

Answers

  • "used only when unicode text is to be entered."

    That is incorrect. NVARCHAR will work for non-unicode as well, though, iiuc, it is converted to unicode. Therefore, NVARCHAR has everything VARCHAR has and then some.

    The concern is as Kent put it, NVARCHAR uses another byte for each character, and hence wastes space (and therefore some minor amount of processing time). Therefore, if NVARCHARs capabilities are not being used, as in your case of only English, it would waste space using NVARCHAR and might be better to use VARCHAR.


    Wednesday, January 11, 2012 2:49 PM
    Answerer
  • Yes, I would use varchar if you are never going to enter unicode strings.  nVarchar requires two bytes for each character; varchar requires one byte.
    • Marked as answer by OldEnthusiast Thursday, January 12, 2012 1:23 PM
    Wednesday, January 11, 2012 12:34 PM

All replies

  • Yes, I would use varchar if you are never going to enter unicode strings.  nVarchar requires two bytes for each character; varchar requires one byte.
    • Marked as answer by OldEnthusiast Thursday, January 12, 2012 1:23 PM
    Wednesday, January 11, 2012 12:34 PM
  • "used only when unicode text is to be entered."

    That is incorrect. NVARCHAR will work for non-unicode as well, though, iiuc, it is converted to unicode. Therefore, NVARCHAR has everything VARCHAR has and then some.

    The concern is as Kent put it, NVARCHAR uses another byte for each character, and hence wastes space (and therefore some minor amount of processing time). Therefore, if NVARCHARs capabilities are not being used, as in your case of only English, it would waste space using NVARCHAR and might be better to use VARCHAR.


    Wednesday, January 11, 2012 2:49 PM
    Answerer