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 2008 Forums
 Transact-SQL (2008)
 sql regex checks?

Author  Topic 

cipriani1984
Constraint Violating Yak Guru

304 Posts

Posted - 2011-02-07 : 07:17:43
Hi,

Im trying to write a function that checks the letters, characters in the field are readable?

As the etl we have loads all the data from the files we gain, but trying to work out which have crap data.

So if companyname comes up as -(#$/ etc i want to flag up, or any unicode foriegn symbols like windings etc.

Thanks in advance.

MIK_2008
Master Smack Fu Yak Hacker

1054 Posts

Posted - 2011-02-07 : 07:50:31
PATINDEX
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2011-02-07 : 07:52:50
SQL Server hasn't had any real support for regex, so people have had to resort to clr integration to use them -> http://msdn.microsoft.com/en-us/magazine/cc163473.aspx. However, I just learned when doing a bit of research for my answer to this topic that the Master Data Services in 2008 R2 has some regex-support. I haven't really looked that much in to it yet but it looks promising:

http://msdn.microsoft.com/en-us/library/ee633712(SQL.105).aspx

- Lumbago
My blog-> www.thefirstsql.com
Go to Top of Page

cipriani1984
Constraint Violating Yak Guru

304 Posts

Posted - 2011-02-07 : 08:04:36
So theres nothing able to use to check wether the field is readable or not?

Just trying to avoid stuff like

???????-????????

AND

???

Thats actually coming out of the database from the files coming in
etc.


quote:
Originally posted by Lumbago

SQL Server hasn't had any real support for regex, so people have had to resort to clr integration to use them -> http://msdn.microsoft.com/en-us/magazine/cc163473.aspx. However, I just learned when doing a bit of research for my answer to this topic that the Master Data Services in 2008 R2 has some regex-support. I haven't really looked that much in to it yet but it looks promising:

http://msdn.microsoft.com/en-us/library/ee633712(SQL.105).aspx

- Lumbago
My blog-> www.thefirstsql.com

Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2011-02-07 : 09:54:37
Try this:
where Col like '%[^A-Za-z0-9][^A-Za-z0-9]%'

to find values with more than one not wanted character in sequence...


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2011-02-08 : 05:34:33
I actually created a blog post about my findings in regards to Regular Expressions. It is in fact possible and here is how you enable the functionality: http://thefirstsql.com/2011/02/07/regular-expressions-advanced-string-matching-and-new-split-function-sql-server-2008-r2/

- Lumbago
My blog-> www.thefirstsql.com
Go to Top of Page
   

- Advertisement -