Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 What does the N do in this stmt: select...N'Test%'

Author  Topic 

bogey
Posting Yak Master

166 Posts

Posted - 2007-04-06 : 14:03:42
USE [TEST]
SELECT [last_name] FROM users.[UOP_User]
WHERE last_name LIKE N'B%'

Whats the purpose of the N after the like?

thanks

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-04-06 : 14:08:38
It is for unicode data, such as nvarchar data type. If you aren't using unicode data types, then you don't need it.

Tara Kizer
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

bogey
Posting Yak Master

166 Posts

Posted - 2007-04-06 : 16:19:01
quote:
Originally posted by tkizer

It is for unicode data, such as nvarchar data type. If you aren't using unicode data types, then you don't need it.

Tara Kizer
http://weblogs.sqlteam.com/tarad/



I could not find this in the sql books online?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-04-06 : 16:20:15
I found it in my head.

Tara Kizer
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2007-04-06 : 17:18:12
quote:
Originally posted by tkizer

I found it in my head.

Tara Kizer
http://weblogs.sqlteam.com/tarad/



Did that require anesthesia



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

pootle_flump

1064 Posts

Posted - 2007-04-07 : 16:30:18
The N explicitly converts the the text to unicode which is slightly more efficient than the engine implicitly converting it, therefore it is not mandatory. I don't know of a BoL entry that explains it in detail. The entry for NCHAR does mention it as a comment in one of the code samples.
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2007-04-10 : 18:07:48
Per BOL:
Unicode constants are specified with a leading N: N'A Unicode string'.
For what it is worth..
Go to Top of Page
   

- Advertisement -