Quick technique to retrieve alphanumeric values by using regular expression in TSQL

This post was written by namwar on September 14, 2008
Posted Under: How-To, TSQL, Tips

If you have a column in a database which contains numeric, alphanumeric and only aplha values and you just want to find all those rows which have alphanumeric values i.e which contains atleast one numeric alongwith anynumber of alphabets then you can use the power of Like operator and a little regular expression technique. Following is a query for Name column in Production.Product table ofAdventureWorks database. This query retrieves all rows which contains alphanumeric values:

 

Use AdventureWorks

Go

Select * from Production.Product Where Name like ‘%[0-9]%’

Go

 

Add a Comment

required, use real name
required, will not be published
optional, your blog address