• Alan.B - Wednesday, February 28, 2018 12:42 PM

    ZZartin - Wednesday, February 28, 2018 12:33 PM

    Another option is to use TRY_CONVERT() if you want to make sure it'll actually convert to something in SQL server 

    select 'yes'
    where TRY_CONVERT(decimal(29, 9), @SearchVal) IS NOT NULL

    Good solution and would probably be fine. Note this though: 

    SELECT TRY_CONVERT(decimal(29, 9), $)

    The pattern that he is trying to match excludes strings that represent negative numbers, which the TRY_CONVERT will not.  Of course, it's easy to modify the WHERE clause to only return positive (or non-negative numbers) or to modify the pattern to match negative numbers.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA