Tuesday, August 1, 2017

Difference between nvarchar and ntext in Sql Server


  • Both can store unicode and non-unicode characters.
  • All types of string functions such as left, right, len, etc. can be used for Nvarchar data type where as only limited functions like substring, datalength can be used for Ntext datatype.
  • Length can be specified in advance for nvarchar datatype i.e. nvarchar(200), nvarchar(2000) where as in Ntext datatype length cannot be specified.
  • Nvarchar datatype can be used in local variables where as this is not possible in Ntext datatype.
  • Nvarchar datatype is available from version 2005 onwards and will be supported for further releases where as Ntext will be removed from future release of SQL Server and will be substituted by nvarchar(max) datatype.
  • Ntext Stores text As Large Object Structure (LOB) in database while NVARCHAR behaves by default store text in table structure and behaves like NTEXT (LOB Structure ) only when it exceeds 8000 Bytes.