|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Monday, July 11, 2005 2:33 PM
Points: 5,
Visits: 1
|
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: 2 days ago @ 12:40 AM
Points: 11,
Visits: 191
|
|
I modified your code to make it more useful.
DECLARE @s NVARCHAR(MAX) DECLARE @result INT DECLARE @count_me NVARCHAR(MAX)
/* The string to be searched. */ SET @s = '1101001001110101'
/* The character to be counted. */ SET @count_me = '00'
/* Replace the character to be counted with empty string, and subtract the lengths. */ SET @result = (LEN(@s) - LEN(REPLACE(@s,@count_me,'')) )/LEN(@count_me)
/* Do something with the result */ PRINT @result
|
|
|
|