Tuesday, 26 November 2013

NVarchar (in SQL Server) - the mysterious 'N'

Sometimes the most preferred data type can cause problems due to the stereotyped acceptance that if it is the most adopted and works, it must be the best.

NVarchar is one such type.

Although this SQL type is quite likely the 'good' one and the 'chosen' one for all text type data requirements, it is not for at least two common requirements related to data-warehousing and transport.

1. Not to be used if the requirement is to have a columnar storage index.
2. Not to be used if the requirement is to export data in a flat file. I made this as a note for some future reference for myself but upon re-read it falls 'flat' !

The 'N' of course is extremely useful as a type prefix if you wish to avoid collating an entire database because just changing the data type of the table column to 'N' type will enable non-English text to be inserted into the column due to the unicode compatibility of the 'N' type.

No comments: