//Posted By Suresh
Declare @Str varchar(100), @CStr Varchar(5)
Set @Str = 'Hi, My self Suresh Chand' -- String
Set @CStr = 'S' --Finding Character
-- Not case-sensitive
select (LEN(@Str) - LEN(REPLACE(@Str, @CStr, '')))
-- Case-sensitive
SELECT (LEN(@Str) - LEN(REPLACE(@Str COLLATE SQL_Latin1_General_Cp1_CS_AS, @CStr COLLATE SQL_Latin1_General_Cp1_CS_AS, '')))
No comments:
Post a Comment