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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to count number of occurence

Author  Topic 

vaibhavktiwari83
Aged Yak Warrior

843 Posts

Posted - 2010-02-25 : 04:25:58
hi everyone,

how can find out number of occurence in a perticular string.

for ex. 'amtruta ambarnath'
if i want to find out how many 'a' is present in that string.


Vabhav T

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-02-25 : 04:28:36
[code]
select len(str) - len(replace(str, 'a', ''))
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

vaibhavktiwari83
Aged Yak Warrior

843 Posts

Posted - 2010-02-25 : 04:30:34
Very good i got it thanks for quick reply...

Vabhav T
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-02-25 : 05:28:05
This may also be helpful
http://beyondrelational.com/blogs/madhivanan/archive/2007/12/21/count-number-of-words-in-a-string.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -