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)
 regular expression

Author  Topic 

rnbguy
Constraint Violating Yak Guru

293 Posts

Posted - 2007-06-24 : 18:37:07
does anyone here know if this is possible using tsql, im trying to write a query which finds a result of a regular expression and uses that result to alter a row (set based approach):

select examplea=resultA
from tableA
where patindex('%[^a-z][a-z][^a-z]%',a.address)!=0

in this case I want resultA to be what matched the [a-z] in the pat index, i know this may not be clear or possible but thought id try, also i know i can just ad all the possibilities of a-z in another table and do it that way but am curious if theres another quicker way.

nr
SQLTeam MVY

12543 Posts

Posted - 2007-06-25 : 08:04:26
select examplea=substring(a.address, patindex('%[^a-z][a-z][^a-z]%',a.address), 3)
from tableA
where patindex('%[^a-z][a-z][^a-z]%',a.address)!=0

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

rnbguy
Constraint Violating Yak Guru

293 Posts

Posted - 2007-06-26 : 21:01:35
mate i wish i could come upto u and shake ur hand, good work thanx :)
Go to Top of Page
   

- Advertisement -