It's typical bad habit to specify a regular character string literal when the filtered column is of a Unicode type Example:
SELECT empid, firstname, lastname
FROM HR.Employees
WHERE lastname = 'Davis'
Why:
The column and the literal have types, SQL Server implicitly converts one operand's type to the other.
But:
In this example,SQL Server converts the literal's type to the column's type, so it can still efficiently rely on indexing.
The Proper form:
SELECT empid, firstname, lastname
FROM HR.Employees
WHERE lastname = N'Davis'
reference:Training Kit Query SQL Server 2012,CHAPTER 3,page 68
No comments:
Post a Comment