Connecting Tech Pros Worldwide Forums | Help | Site Map

sql query

Newbie
 
Join Date: Feb 2007
Posts: 26
#1: May 29 '07
hi to all

i am sridhar

i have 1 doubt

Query to select the text after a particular character


for example

Sridhar's

i want to select the text after ' (single quote)

the result is 's'

i need query for this


thanks

chandu031's Avatar
Expert
 
Join Date: Mar 2007
Posts: 76
#2: May 29 '07

re: sql query


Quote:

Originally Posted by sridhar21

hi to all

i am sridhar

i have 1 doubt

Query to select the text after a particular character


for example

Sridhar's

i want to select the text after ' (single quote)

the result is 's'

i need query for this


thanks

Hi,

This is the query:
Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT SUBSTRING('SRIDHAR''S',CHARINDEX('`','SRIDHAR`S',1)+1,LEN('SRIDHAR''S'))
  3.  
  4.  
However this will not work if you are looking for the second or higher instances of the search character(apostophe in your case).

Cheers!
Newbie
 
Join Date: May 2007
Posts: 15
#3: May 29 '07

re: sql query


SELECT right(Description,len(Description) - charindex(char(39), Description))

Here Description is the name such as "sridhar's"
char(39) = " ' "

However this will not work if you are looking for the second " ' "
Reply


Similar Microsoft SQL Server bytes