• I misunderstood the OP and updated my function to do what I think you are trying to do (it was originally searching for an id instead of six consecutive integers. What I am still not clear about is if this:

    Customer ID Address

    6237 025 OHIO DR APT 13111

    9261 123 main street #1567

    8036 12 lee street #8956345

    Represents a table or a string. If it represents a table then Sean understood your requirement correctly and you just need to return records from a column that contain 6 consecutive numbers then what Sean posted is exactly what you need. If Sean was mistaken and you are looking for to extract that information from a string then the function I posted will give you what you want. In my previous post I demonstrated how pull this information from a variable or parameter. Below is how you would do it if the information was in a table...

    -- getting this information from a variable or parameter

    DECLARE @string varchar(200)=

    'Customer ID Address

    6237 025 OHIO DR APT 13111

    9261 123 main street #1567

    8036 12 lee street #8956345';

    SELECT *

    FROM dbo.string_to_table(@string)

    WHERE customer_address LIKE N'%[0-9][0-9][0-9][0-9][0-9][0-9]%'

    -- getting this information from a table

    ;WITH customer_import_data(id, cust_data) AS

    (SELECT 1,

    'Customer ID Address

    6237 025 OHIO DR APT 13111

    9261 123 main street #1567

    8036 12 lee street #8956345'

    UNION

    SELECT 2,

    'Customer ID Address

    5537 333 DELEWARE APT 222

    6133 888 main street #2

    5555 55 hee Ave #44558899'

    )

    SELECT customer_id, customer_address

    FROM customer_import_data cd

    CROSS APPLY dbo.string_to_table(cd.cust_data) sp

    WHERE customer_address LIKE N'%[0-9][0-9][0-9][0-9][0-9][0-9]%'

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001