Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server T-SQL N prefix on string literal [duplicate]

It's maybe a noob question but I found some T-SQL query example to verify database size with SELECT and WHERE clause here

Here is the code:

SELECT name, size, size*1.0/128 AS [Size in MBs] 
FROM sys.master_files
WHERE name = N'mytest';

My question is what does the N prefix mean in the WHERE name = N'keyword' clause?

I always use WHERE name = 'keyword' before, and I don't find the differences (you can try it by yourself).

I've googled that but I don't know the keyword I supposed to search

like image 653
Willy Lazuardi Avatar asked Dec 25 '22 19:12

Willy Lazuardi


1 Answers

It's declaring the string as nvarchar data type (Unicode), rather than varchar (8-bit encoding, including ASCII).

FYI, this is a duplicate of the question: What is the meaning of the prefix N in T-SQL statements?

like image 72
Doug_Ivison Avatar answered Dec 28 '22 09:12

Doug_Ivison