Wednesday, February 3, 2021

Typical Testing Day

 

            Recently I came across a situation where I need to find whether a particular column has an integer value or varchar...there could be many ways to find the outcome however found the below query which is very simple.

Let us say we have a table called EMPLOYEE and ID is a varchar column, I need to find records which as integer or char.

SELECT * FROM EMPLOYEE

                    WHERE ID LIKE '%[^0-9]%' -- Looks for 0-9

                     OR ID LIKE '_%-%' -- Looks for the '-' other than 1st position.


No comments: