nvarchar UTF ?

techresearch7777777 1,981 Reputation points
2024-01-29T18:45:39.34+00:00

Hello, please correct me if I'm wrong or missing something...believe nvarchar is UTF-16 but is the output always utf-8 ? Thanks in advance.

SQL Server | Other
{count} votes

Accepted answer
  1. Azar 29,520 Reputation points MVP Volunteer Moderator
    2024-01-29T18:52:51.3666667+00:00

    Hey techresearch7777777

    Thanks for posting the question in QandA platform,

    Nope, your understanding is not right. lemme clarify here, so nvarchar in SQL Server is indeed a Unicode character data type, but it uses the UTF-16 encoding, not UTF-8.

    by default. The output remains UTF-16 for nvarchar in SQL Server.

    If you are looking for a need to use UTF-8 action, SQL Server 2019 introduced nvarchar(max) for that purpose.
    https://learn.microsoft.com/en-us/search/?terms=navchar%20sql&category=Documentation

    If this helps kindly accept the answer thanks much.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Olaf Helper 47,441 Reputation points
    2024-01-29T19:33:58.4733333+00:00

    nvarchar is UTF-16 but is the output always utf-8 ?

    It's neither nor; it's always Unicode, see https://learn.microsoft.com/en-us/sql/t-sql/functions/unicode-transact-sql https://en.wikipedia.org/wiki/Unicode


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.