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)
 Find patterns using T-SQL, regular expressions

Author  Topic 

bmathew
Starting Member

1 Post

Posted - 2009-03-29 : 16:41:44
Hi,

I have a problem where credit card authorization codes are stored in a column in which users were writing other data such as notes or comments.

The credit card authorization code is in this format:

8 alpha/numeric characters - 4 alpha/numeric characters - 4 alpha/numeric characters - 4 alpha/numeric characters - 12 alpha/numeric characters

Here is an example of a code:
AK997B56-4024-42A6-9912-068800DBB3K7

I need to remove only the code from the column. Is there a way to search for this pattern inside my column so I can remove the code an write to a new column?

Thanks,
Binu Mathew

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-03-30 : 09:19:29
Assuming this is the pattern for all credit card authorization codes...Can't you just extract the first 36 characters from that column.

SELECT LEFT(<column>,36) from <urtable>
Go to Top of Page
   

- Advertisement -