22,299
社区成员




create function comstr(@s1 varchar(100), @s2 varchar(100))
returns int
as
begin
declare @len int, @i int, @diff int
select @len=len(@s1), @i=1, @diff=0
while @i<=@len
begin
if substring(@s1,@i,1)<>substring(@s2,@i,1) set @diff+=1
if @diff>3 return 128
set @i+=1
end
return @diff
end
go
select dbo.comstr('1q2w3e4r5t6y7u8i9o0p','kq2w3e4r5t6y7u8i9o0p')
select dbo.comstr('1q2w3e4r5t6y7u8i9o0p','kq2w3abcdefg7u8i9o0p')