Search

Showing posts with label Count Occurrences of Characters. Show all posts
Showing posts with label Count Occurrences of Characters. Show all posts

Tuesday, January 25, 2011

Count Occurrences of Characters in a String – SQL Server

Count the occurrences of characters in a string, stored in our SQL Server Database.
DECLARE @longWord varchar(28)='Thisissqlanddotnetdevelopment'
SELECT CountCharacters = DATALENGTH(@longWord)
- DATALENGTH (REPLACE(REPLACE(LOWER(@longWord),'a',''),'i',''))