0

What does it mean N'some string' in SQL Server. I mean if I can use it to prevent against SQL Injection?
For example:
... LIKE N'%somePattern%'
Is SQL Injection safe ?

2 Answers2

2

The N has nothing to with SQL injection. You need to use it when you use unicode data

From msdn:

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.

James Z
  • 12,209
  • 10
  • 24
  • 44
1

It means the string is an nchar as opposed to a char (see What is the difference between char, nchar, varchar, and nvarchar in SQL Server?)

It's purely about the datatype - nothing to do with SQL injection at all.

Community
  • 1
  • 1
RB.
  • 36,301
  • 12
  • 91
  • 131