declare @myvar varchar(20) set @myvar = 'Hello World' select len(@myvar) - len(replace(@myvar,'o',''))