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 |
VGuyz
Posting Yak Master
121 Posts |
Posted - 2008-07-30 : 08:24:39
|
how to find the no.of comma in a stringfor ex:inputstring='11,22,33,34,35'output4----Total no of commos |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-07-30 : 08:25:16
|
[code]select len(string) - len(replace(string, ',', ''))[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-07-30 : 08:25:57
|
quote: Originally posted by VGuyz how to find the no.of comma in a stringfor ex:inputstring='11,22,33,34,35,'output4----Total no of commos
Shouldn't it be 5 ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-07-30 : 08:28:14
|
declare @s varchar(100)set @s='11,22,33,34,35'select len(@s)-len(replace(@s,',',''))MadhivananFailing to plan is Planning to fail |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-07-30 : 08:28:36
|
MadhivananFailing to plan is Planning to fail |
 |
|
VGuyz
Posting Yak Master
121 Posts |
Posted - 2008-07-30 : 09:26:50
|
Thanks for spending u'r time for me.. |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-07-31 : 09:56:29
|
quote: Originally posted by VGuyz how to find the no.of comma in a stringfor ex:inputstring='11,22,33,34,35'output4----Total no of commos
What did you change in the question?MadhivananFailing to plan is Planning to fail |
 |
|
VGuyz
Posting Yak Master
121 Posts |
Posted - 2008-07-31 : 10:41:09
|
quote: for ex:inputstring='11,22,33,34,35,'output4----Total no of commos
Removed the ','.Thats all mathi. |
 |
|
|
|
|
|
|