| Author |
Topic |
|
zubamark
Starting Member
23 Posts |
Posted - 2006-03-24 : 13:34:15
|
| Hi, Can you helpI have a string that has multiple commas:'AAA,BBB,CCC,DDD,EEE,...'I need to pick any characters between commas or find all commas positions. |
|
|
Srinika
Master Smack Fu Yak Hacker
1378 Posts |
Posted - 2006-03-24 : 14:02:37
|
| >> any characters between commas U mean split the string to several and display as different rows?>>find all commas positionsHow do u want the output to be?U mean 4,8,12,16,20or48121620or what ?Give the out put u expect - with respect to the sample |
 |
|
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2006-03-24 : 15:13:05
|
| see thishttp://www.sqlteam.com/forums/topic.asp?TOPIC_ID=63664 |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-03-24 : 18:40:44
|
use the function here http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=50648 KHChoice is an illusion, created between those with power, and those without.Concordantly, while your first question may be the most pertinent, you may or may not realize it is also the most irrelevant |
 |
|
|
RyanRandall
Master Smack Fu Yak Hacker
1074 Posts |
Posted - 2006-03-27 : 13:38:22
|
--inputdeclare @s varchar(100)set @s = 'AAA,BBB,CCC,DDD,EEE,...'--numbers tableDECLARE @numbers TABLE (i INT IDENTITY(1, 1), c char(1), marker tinyint)INSERT @numbers SELECT TOP 101 NULL, 0 FROM master.dbo.syscolumns--comma positionsselect i from @numbers where substring(@s, i, 1) = ','--characters between commasselect substring(@s, i, charindex(',', substring(@s+',', i, 100))-1)from @numbers where substring(',' + @s, i, 1) = ','--rolled up comma positionsdeclare @t varchar(100)set @t = ''select @t = @t + cast(i as varchar(10)) + ',' from @numbers where substring(@s, i, 1) = ','print left(@t, len(@t)-1)I need more restraint!Ryan Randallwww.monsoonmalabar.comIdeas are easy. Choosing between them is the hard part. |
 |
|
|
|
|
|