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 |
|
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 alonesenthilkumar |
|
|
Ohmslaw
Starting Member
11 Posts |
Posted - 2009-01-16 : 18:21:41
|
| QUOTENAME ( 'character_string' [ , 'quote_character' )This function may help.Ohms... |
 |
|
|
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] |
 |
|
|
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 quotationsenthilkumar |
 |
|
|
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 charactersHere is how I replace underscores in part numbers with an empty space.replace(partnumber, '_', '')r&r |
 |
|
|
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 ultimatesenthilkumar |
 |
|
|
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 quotesexample consider --> 'country sports "club" "ultimate" 'how to get these both club and ultimatesenthilkumar |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-01-20 : 04:41:16
|
| try this oncedeclare @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 valueFROM @str AS sINNER 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) = ' ' |
 |
|
|
|
|
|
|
|