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.
| Author |
Topic |
|
umertahir
Posting Yak Master
154 Posts |
Posted - 2010-01-08 : 12:04:48
|
| How do I pick out last name of a string of text?e.g., Varchar text is : 'Morgan K Lens'I want to pick up 'lens' from the first example. |
|
|
blindman
Master Smack Fu Yak Hacker
2365 Posts |
|
|
umertahir
Posting Yak Master
154 Posts |
Posted - 2010-01-08 : 12:11:23
|
I have tried the following code:SELECT RIGHT('MORGAN K LENS', CHARINDEX(' ', REVERSE('MORGAN K LENS')))Result:LENS |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-01-08 : 12:16:33
|
quote: Originally posted by umertahir I have tried the following code:SELECT RIGHT('MORGAN K LENS', CHARINDEX(' ', REVERSE('MORGAN K LENS')))Result:LENS
this will work as long as your name format is consistent with at least 2 parts |
 |
|
|
|
|
|