Unicode and SQL Server

This post is more than 2 years old.

Ok, let me begin this by stating that I am not a DBA, so someone may correct me. I found out today that just because you use nvarchar or ntext or any other unicode field type in SQL Server, the data may not actually be stored in Unicode. If you do not prepend your SQL statements with N, the data isn't treated as Unicode. So, for example, to store string 'foo' as Unicode, you need to do N'foo'.

Now, this is news to me, and it seems a bit silly. If I specify column X as Unicode, why in the hell do I have to force the issue when I'm writing SQL?

I've actually never even seen that syntax before - has anyone else?

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate for HERE Technologies. He focuses on JavaScript, serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA https://www.raymondcamden.com