Solved

Regular Expressions within SQL?

Posted on 2006-07-03
6
2,798 Views
Last Modified: 2008-01-09
Is it possible to incorporate regular expressions with SQL statements? For example, I want to return all records with a correctly constructed email address.

Cheers.
0
Comment
Question by:paulbradley
6 Comments
 
LVL 18

Expert Comment

by:Ravi Singh
Comment Utility
I don't think the standard SQL supports complex regular expressions (someone can correct me if im wrong!) such as extracting valid email addresses, if your using some conventional high level programming language you could retrieve all email addresses using a select statement then iterate through these and find valid email addresses with the languages' support for regex's.

It also might be worth having a pointer to this question from a DB topic area
0
 
LVL 6

Accepted Solution

by:
Taconvino earned 250 total points
Comment Utility
Hi!

I agree with Zephyr.  I don't think RegExp is supported by standard SQL.  You can look here:

http://www.sqlservercentral.com/columnists/mcoles/sql2000dbatoolkitpart2.asp

This is the second part of a very usefull article by Michael Coles.  I'm not sure, but I think it requires registration to look at (it's a free registration).

TCV
0
 
LVL 84

Expert Comment

by:ozo
Comment Utility
MySQL supports
str REGEXP pat
but regular expressions are not very good for matching correctly constructed email addresses
doing it properly using a regular expression requires a pattern that's thousands of characters long.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 2

Expert Comment

by:eechincs
Comment Utility
Agree with above,for me i rather have the detail validation on the emails format before inserting into the table.....then sure all the emails in the database are in correct format
0
 

Author Comment

by:paulbradley
Comment Utility
Cheers for these remplies.

Basically I'm using Group Mail and linking it to an external database and using SQL queries to import only the data I'm interested in. I know I should validate as close to capture as possible but the database already has a high number of records and it's read only (it's the backend to my online shopping cart software).

I was hoping to be able to only import correctly constructed email addresses to minimise bouces, I don't think this seems possible without moving validation on to the web site - unless anyone can suggest anything?

Cheers.
0
 
LVL 1

Expert Comment

by:nicolasn
Comment Utility
MS SQL 2005 supports user defined functions written in .Net languages.  You could get access to regular expressions like that if you are using the right verison of MS SQL.

I am not a DB expert, others may give better answers, but a UDF may be what you want.

Nicolas
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now