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.
| Author |
Topic |
|
ksandell
Starting Member
1 Post |
Posted - 2011-07-24 : 17:56:50
|
| Using SQL 2008 and got the basics down, but...(I can do this in python, but it too slow at 1000 rows/sec.)I need to conduct string manipulation using regex against a column in a table, through 2 different approaches:1) update table set [column] = ([column]<replace non-alphanumeric characters with a single space>)2) select ([column]<replace non-alphanumeric characters with a single space>) as [alias] into new_table from tableI've worn out Google looking for this, at least I'm tired to looking through examples that don't seem to exhibit this in a simple fashion or well explained fashion.Any simple examples would be greatly appreciated, or well explained complex examples.Thanks |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2011-07-24 : 18:24:09
|
| There is no regular expression capability natively built into T-SQL. So your only choices within T-SQL are REPLACE function or STUFF function, which are very limited as stand-ins for regular expressions; they do not allow character-classes for example.However, SQL 2005 and SQL 2008 support CLR integration, so you can create CLR functions/stored procs which can take full advantage of the .Net frame work class libraries, including the Regex class in .Net. There are several examples online, this page for example.If you are on SQL 2008 R2, another option is to use regex capabilities from Master Data Services. This page has information and examples. I have not experimented with this approach, but this blog is by a regular contributor to SQLTeam forum. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|
|
|