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
 General SQL Server Forums
 New to SQL Server Programming
 CHARINDEX HELP

Author  Topic 

Chris_Kelley
Posting Yak Master

114 Posts

Posted - 2014-09-10 : 10:11:06
c

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2014-09-10 : 10:27:45
First please check your data for possible values.
For example:
Chris Kelley
Paul E. Newman
Dwayne "The Rock" Douglas Johnson
...


Too old to Rock'n'Roll too young to die.
Go to Top of Page

Chris_Kelley
Posting Yak Master

114 Posts

Posted - 2014-09-10 : 10:34:56
c
Go to Top of Page

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2014-09-10 : 12:11:46
See this example:
DECLARE @name VARCHAR(32) = 'Chris Kelley';
SELECT LEFT(@name, PATINDEX('% [^ ]%',@name)+1);
Go to Top of Page

Chris_Kelley
Posting Yak Master

114 Posts

Posted - 2014-09-10 : 21:13:46
c
Go to Top of Page
   

- Advertisement -