Home Forums SQL Server 2008 T-SQL (SS2K8) tsql query - Count the number of spaces in a string RE: tsql query - Count the number of spaces in a string
ColdCoffee
SSC-Dedicated
Points: 39971
More actions
June 19, 2012 at 1:53 pm
#1503083
This?
DECLARE @String VARCHAR(100)
,@CharToFind VARCHAR(1)
SET @String = 'AAAA BBBCB NNNNN NEEEEE ERERERERERE '
SET @CharToFind = ' '
SELECT CountOfCharsInTheString = DATALENGTH (@String) - DATALENGTH(REPLACE(@String,@CharToFind,''))