Search

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',''))

No comments:

Post a Comment