Search code examples
sql-servertextvarcharsqldatatypesnvarchar

To handle special characters in SQL server database, which should be used varchar or nvarchar?


I am asking a simple question that, to handle special characters in my Mobile/Tablet web app, which data types should I use?

  1. Varchar
  2. NVarchar
  3. Text
  4. NText

EDIT:

IMPORTANT! ntext, text, and image data types will be removed in a future version of SQL Server. Avoid using these data types in new development work, and plan to modify applications that currently use them. Use nvarchar(max), varchar(max), and varbinary(max) instead. More Detail Here

Should we use nVarchar as I read somewhere that some devices, such as mobile phones, still cannot correctly handle Unicode data.

Please give your expert suggestions?


Solution

  • 1 or 2 depending on the "special characters" you'll be saving. Just depends on how "special" they are.

    I will say though, definitely not Text as it's deprecated.

    https://learn.microsoft.com/en-us/sql/t-sql/data-types/ntext-text-and-image-transact-sql?view=sql-server-2017