clear markdown compare help best fiddles feedback
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 2805438 fiddles created (40862 in the last week).

CREATE FUNCTION dbo.FindFirstDeff( @FirstStr VARCHAR(300), @SecondStr VARCHAR(300) ) RETURNS INT AS BEGIN DECLARE @Value INT = -1; WITH CTE AS ( SELECT 1 Num UNION ALL SELECT Num + 1 FROM CTE WHERE Num < (SELECT CASE WHEN LEN(@FirstStr) > LEN(@SecondStr) THEN LEN(@FirstStr) ELSE LEN(@SecondStr) END) ) , F AS ( SELECT *, @SecondStr Str1, @SecondStr Str2, CASE WHEN SUBSTRING(@FirstStr, Num, 1) = SUBSTRING(@SecondStr, Num, 1) THEN 0 ELSE 1 END IsTheSame FROM CTE ) SELECT TOP 1 @Value = Num FROM F WHERE IsTheSame = 1 ORDER BY Num ASC OPTION (MAXRECURSION 300); RETURN(@Value); END
 hidden batch(es)

SELECT dbo.FindFirstDeff('Interesting', 'Interested')
(No column name)
 hidden batch(es)