Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Execute regular expressions in SQL

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-08-01 : 08:28:54
Bernardo writes "I want to know if SQL can execute Regular Expressions, this is, can I do "select (field regexp '^[0-9]*$');".

MySQL has that functionality included, and Oracle can do it with a package, but I have not found a way to do it within SQL.

Regards
Bernardo
berzamora@yahoo.com"

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-08-01 : 08:32:23
Not directly. It will almost certainly be available in the next release of SQL Server (Yukon).

I'm not a regexp guru, but I think the following is equivalent to your example:

SELECT * FROM myTable WHERE field LIKE '%[^0-9]'

It's not exact but it's close. You can always have multiple patterns and use AND in the WHERE clause to combine them, or modify it to use a complementary pattern and then use NOT to reject those rows.

Go to Top of Page
   

- Advertisement -