How to find duplicate digits in the middle of similar numbers? In my table, a column has the following values:

1234567890
2086567845
    ^^^^ duplicate digits


So the above values have 4 digits in the middle which are duplicates.


How could I find these automatically?
Here is one method for doing that.  It assumes that the strings are all the same length and you really want to find all the cases where the middle string is duplicated.  

Finds all duplicate "middle", update the CTE_Split to use your actual table and column names as appropriate.   

;WITH CTE_Split AS
    (
    SELECT ID
        , LEFT(ValueString, 4) AS PreFix
        , SUBSTRING(ValueString, 5, 4) AS Middle
        , RIGHT(ValueString, 2) AS Ending
    FROM (VALUES (1, '1234567890')
                , (2, '2086567845')
                ) AS P (ID, ValueString)
    )
, CTE_Duplicate AS
    (
    SELECT ID
        , Prefix
        , Middle
        , Ending
        , RN = ROW_NUMBER() OVER (PARTITION BY Middle ORDER BY ID)
    FROM CTE_Split
    )
SELECT ID, Prefix, Middle, Ending, RN 
FROM CTE_Duplicate 
WHERE Middle IN (   SELECT Middle 
                    FROM CTE_Duplicate 
                    WHERE RN &gt;= 2
                    )