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 2012 Forums
 Transact-SQL (2012)
 CHARINDEX ( N, help?)

Author  Topic 

MelissaTsalicoglou
Starting Member

16 Posts

Posted - 2014-06-04 : 14:12:55
Please can you assist?

What does the N refer to ?
SUBSTRING(contactname, 0, CHARINDEX(N',', contactname)) as lastname

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-06-04 : 14:19:56
It is for unicode purposes. If contactname isn't using unicode data type, then it is not needed.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

MelissaTsalicoglou
Starting Member

16 Posts

Posted - 2014-06-04 : 14:23:07
thanks very much
therefore the code takes from the first letter up until the comma as the last name?


quote:
Originally posted by tkizer

It is for unicode purposes. If contactname isn't using unicode data type, then it is not needed.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/

Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-06-04 : 14:42:06
quote:
Originally posted by MelissaTsalicoglou

thanks very much
therefore the code takes from the first letter up until the comma as the last name?




Yes, typically you'll see 1 instead of 0 for the second parameter for SUBSTRING. CHARINDEX finds the position of the comma.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page
   

- Advertisement -