Home Forums SQL Server 2005 Development How to get a row number which is failing during conversion RE: How to get a row number which is failing during conversion

  • Ok assuming all your values are numeric then try this:

    in the where clause

    CHARINDEX('.',col1) > 6

    OR

    (CHARINDEX('.',col1) = 0 AND LEN(col1) > 5)

    Here is my example for returning values that would overflow.

    DECLARE @Tmp TABLE

    (COl1 VARCHAR(100))

    INSERT INTO @Tmp

    SELECT '1' UNION ALL

    SELECT '1' UNION ALL

    SELECT '1' UNION ALL

    SELECT '1' UNION ALL

    SELECT '1' UNION ALL

    SELECT '1' UNION ALL

    SELECT '1' UNION ALL

    SELECT '1' UNION ALL

    SELECT '1' UNION ALL

    SELECT '92345.1234567' UNION ALL

    SELECT '12345.12345671' UNION ALL

    SELECT '123456.1234567' UNION ALL

    SELECT '111111111111111111111111111111' UNION ALL

    SELECT '1234567890'

    SELECT

    --CAST(col1 as decimal(12,7))

    col1

    FROM @Tmp

    WHERE

    CHARINDEX('.',col1) > 6

    OR

    (CHARINDEX('.',col1) = 0 AND LEN(col1) > 5)

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life