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?
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?
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