Search code examples
sql-serverunicodesqldatatypes

Unicode Data Type in SQL


I'm new to Microsoft SQL. I'm planning to store text in Microsoft SQL server and there will be special international characters. Is there a "Data Type" specific to Unicode or I'm better encoding my text with a reference to the unicode number (i.e. \u0056)


Solution

  • Use Nvarchar/Nchar (MSDN link). There used to be an Ntext datatype as well, but it's deprecated now in favour of Nvarchar.

    The columns take up twice as much space over the non-unicode counterparts (char and varchar).

    Then when "manually" inserting into them, use N to indicate it's unicode text:

    INSERT INTO MyTable(SomeNvarcharColumn) 
    VALUES (N'français')