• Or, as an (untested) alternative.

    Select

    Distinct RCD.Variable4

    FROM Route_Call_Detail RCD

    WHERE RCD.[DateTime] > '12/4/10'

    AND RCD.[DateTime] < '12/5/10'

    AND CASE WHEN SUBSTRING(RCD.Variable4, 1, 6) NOT LIKE '%[^0-9]%' THEN CONVERT(INT, SUBSTRING(RCD.Variable4, 1, 6)) ELSE NULL END BETWEEN BETWEEN 5011 AND 7999

    )

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass