CREATE function dbo.skipXtimes(@str nvarchar(max), @char char(1), @times int)
returns nvarchar(max)
as
begin
declare @test int
while @times > 0
begin
set @test = charindex(@char,convert(nvarchar(4000),@str))
if @test>0
select @str=stuff(@str,1,@test,''), @times=@times-1
else
set @times=0
end
return @str
end
GO
|