1

The code I am looking at is this:

        SET @Message = N'Question result is ''' + @CurrentResult + '''. It should be unmarked or incorrect';
        THROW 50002,@Message,1

Can someone explain why the developer but "N" before the quotes?

Pரதீப்
  • 91,748
  • 19
  • 131
  • 172

1 Answers1

2

From MSDN in remarks section

Saying that string is of Nvarchar type and can have unicode charcters

Prefix Unicode character string constants with the letter N. Without the N prefix, the string is converted to the default code page of the database. This default code page may not recognize certain characters.

The "N" prefix stands for National Language in the SQL-92 standard, and must be uppercase. If you do not prefix a Unicode string constant with N, SQL Server will convert it to the non-Unicode code page of the current database before it uses the string.

Here is more detailed information

You must precede all Unicode strings with a prefix N when you deal with Unicode string constants in SQL Server

Pரதீப்
  • 91,748
  • 19
  • 131
  • 172