Tags: column, contains, database, microsoft, mysql, numeric, oracle, server, sql, string, varchar

How to test a string for numeric?

On Database » Microsoft SQL Server

1,034 words with 2 Comments; publish: Tue, 06 May 2008 17:41:00 GMT; (25078.13, « »)

How do I test if a varchar column contains a numeric value?

All Comments

Leave a comment...

  • 2 Comments
    • CREATE TABLE #foo

      (

      bar VARCHAR(12)

      )

      SET NOCOUNT ON

      INSERT #foo SELECT 'aaaaa5aaaa'

      INSERT #foo SELECT '5aaaa'

      INSERT #foo SELECT 'aaaa5'

      INSERT #foo SELECT 'xxxxx'

      INSERT #foo SELECT '.'

      SELECT bar, ContainsNumeric = CASE

      WHEN bar LIKE '%[0-9]%' THEN 'Yes'

      ELSE 'No'

      END

      FROM #foo

      DROP TABLE #foo

      "Snake" <Snake.sqlserver.questionfor.info.discussions.microsoft.com> wrote in message

      news:EF4FDF27-7F2B-4BF9-A8CE-6EE1E5C9C74F.sqlserver.questionfor.info.microsoft.com...

      > How do I test if a varchar column contains a numeric value?

      >

      #2; Tue, 06 May 2008 17:43:00 GMT