Unlimited Web Space

Enjoy Unlimited web hosting

Oct 25, 2011

How to select a word from a sentence or a name.(Parsename)

You have a sentence or a name with multiple words like First name, Second Name, Surname, etc and you
want to write a select statement that will give you a part of the sentence, you can write a SQL query as:

SELECT PARSENAME(REPLACE('You are welcome here', ' ', '.'), 2)



This will return 'welcome'


Or

SELECT PARSENAME(REPLACE('Hello Angelina Jolie', ' ', '.'), 1)
This will return 'Jolie'

No comments:

Post a Comment