clear markdown feedback
clear markdown feedback
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 3364508 fiddles created (40595 in the last week).

DECLARE @Str1 VARCHAR(45) = 'Interesting', @Str2 VARCHAR(45) = 'Interested'; WITH CTE AS ( SELECT 1 Num UNION ALL SELECT Num + 1 FROM CTE WHERE Num < (SELECT CASE WHEN LEN(@Str1) > LEN(@Str2) THEN LEN(@Str1) ELSE LEN(@Str2) END) ) , F AS ( SELECT *, @Str1 Str1, @Str2 Str2, CASE WHEN SUBSTRING(@Str1, Num, 1) = SUBSTRING(@Str2, Num, 1) THEN 0 ELSE 1 END IsTheSame FROM CTE ) SELECT TOP 1 Num FROM F WHERE IsTheSame = 1 ORDER BY Num ASC;
Num
9
 hidden batch(es)