> Under what conditions would someone use the N' in a query?
The N literal prefix denotes a unicode string. This should be specified
when working with unicode data types (nvarchar, nchar, ntext) but not with
non-unicode data types.
Why not just put N in all of the queryies?
When unlike data types are involved, SQL Server will convert values to the
data type with the highest precedence. It's a good practice to specify
literal values that are appropriate so that expressions are sargable. See
the Books Online <tsqlref.chm::/ts_da-db_2js5.htm> for data type precedence
rules.
You need to be mindful of data type precedence to ensure indexes are used
efficiently. Examine the execution plans of the queries below.
USE pubs
SELECT * FROM authors
WHERE au_lname = 'White'
SELECT * FROM authors
WHERE au_lname = N'White'
--
Hope this helps.
Dan Guzman
SQL Server MVP
<sd********@msn.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com... What exactly is happening when a query is sent using the N in front of
the string to be found?
Under what conditions would someone use the N' in a query?
I have been testing out some chinese text. I set up some fields of
nVarchar, nText and it works with an N. Without the N, it wont work.
N also works with fields of varchar and text for english.
Would this ever cause a problem to a query depending on how the
machines regional settings are set? Why not just put N in all of the
queryies?
If anyone has some ideas, I would be grateful for any and all
information about the N.