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
 To get the number of times a character is repeated

Author  Topic 

abhiram_414
Starting Member

14 Posts

Posted - 2008-08-22 : 02:34:25
Hi, I have an application where I have to write a query to get the number of times a character is repeated in string or varchar. Can you please help me..

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-22 : 02:41:35
you want a sql query? it will b like below
SELECT len(yourstring)-len(replace(yourstring,yourcharacter,''))
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-08-22 : 02:57:06
Repeated as in "sequence", or repeated as in "occurencies"?

See http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=75441




E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

abhiram_414
Starting Member

14 Posts

Posted - 2008-08-22 : 03:16:43
Thank you.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-08-22 : 03:43:16
Jusst for clarifying, which of the two approaches did you want?


E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

abhiram_414
Starting Member

14 Posts

Posted - 2008-08-25 : 04:57:40
The first thing that is
SELECT len(yourstring)-len(replace(yourstring,yourcharacter,''))
Which Visakh16 has told.
Go to Top of Page
   

- Advertisement -