Why does N' appear in system generated SQL?

1 minute read time.
You may have seen in the SQL logs that Sage CRM passes strings using an N prefix. This denotes that the subsequent string is in Unicode (the N actually stands for National language character set). Which means that you are passing an NCHAR, NVARCHAR or NTEXT value, as opposed to CHAR, VARCHAR or TEXT.

select pers_lastname, pers_firstname from person where pers_lastname like N'O%'

Unicode is used in Sage CRM to facilitate code pages which extend beyond the English and Western Europe code pages, for example Chinese.



 It is perfectly possible for Sage CRM to hold mixed language data. I have attached some screen shots of a Thai, Arabic and Chinese. These are development screen shots of systems that have now gone live. You will see that these are all mixed data systems with the implementers choosing to hold some data in English (Latin characters) and some in their own doublebyte character sets.

Thank you very much to the colleagues and partners who gave me the images of the sytems.