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
 split double quotes string inside another string

Author  Topic 

ultimate_senthil
Starting Member

13 Posts

Posted - 2009-01-16 : 17:17:16
hi all,

how to get the double quote string inside a string,

parameter get the input like this --> 'country sports "club" '

how to split the input and get the word club alone

senthilkumar

Ohmslaw
Starting Member

11 Posts

Posted - 2009-01-16 : 18:21:41
QUOTENAME ( 'character_string' [ , 'quote_character' )

This function may help.

Ohms...
Go to Top of Page

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2009-01-16 : 18:22:48
[code]declare @param varchar(10)
set @param='club'
print 'country sports '+char(39)+char(39)+@param+char(39)+char(39)
print 'country sports '''''+@param+''''''[/code]
Go to Top of Page

ultimate_senthil
Starting Member

13 Posts

Posted - 2009-01-16 : 19:16:01
ya its getting the output,but the output seems like this

["club"]

i need like this club alone as single word without bracket and quotation

senthilkumar
Go to Top of Page

revdnrdy
Posting Yak Master

220 Posts

Posted - 2009-01-16 : 19:19:44
Then I think you would want to use the replace function since you are removing characters

Here is how I replace underscores in part numbers with an empty space.

replace(partnumber, '_', '')

r&r
Go to Top of Page

ultimate_senthil
Starting Member

13 Posts

Posted - 2009-01-16 : 19:44:05
before replacing how to get multiple words enclosed in the double quotes

example consider --> 'country sports "club" "ultimate" '

how to get these both club and ultimate

senthilkumar
Go to Top of Page

ultimate_senthil
Starting Member

13 Posts

Posted - 2009-01-16 : 20:07:17
quote:
Originally posted by Ohmslaw

QUOTENAME ( 'character_string' [ , 'quote_character' )

This function may help.

Ohms...



how to get multiple words enclosed in the double quotes

example consider --> 'country sports "club" "ultimate" '

how to get these both club and ultimate

senthilkumar
Go to Top of Page

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-01-20 : 04:41:16
try this once
declare @str table(data varchar(128))
insert into @str select 'city country "union" "club" "ultimate"'

SELECT
replace(SUBSTRING(s.data,charindex(' ',s.data,v.number),abs(charindex(' ',s.data,charindex(' ',s.data,v.number)+1)-charindex(' ',s.data,v.number))),'"','')as value
FROM @str AS s
INNER JOIN master..spt_values AS v ON v.Type = 'P'
and v.number > 0
and v.number <= len(s.data)
WHERE substring(' ' + s.data, v.number, 1) = ' '
Go to Top of Page
   

- Advertisement -