rka
SSCommitted
Points: 1599
More actions
March 17, 2014 at 11:50 pm
#305239
Hi,
I have some sample data such as:
AB123 Text Text TextText Text Text AB456Text Text CD789 TextCD010_Text Text TextText Text_EF999 TextText Text_EF888_Text
AB123 Text Text Text
Text Text Text AB456
Text Text CD789 Text
CD010_Text Text Text
Text Text_EF999 Text
Text Text_EF888_Text
I want the output as:
Code------------AB123AB456CD789CD010EF999EF888
Code
------------
AB123
AB456
CD789
CD010
EF999
EF888
What is the best way to write a T-SQL Query to achieve this?
serg-52
SSCrazy Eights
Points: 9913
March 18, 2014 at 1:08 am
#1697878
It totally depends on what is the 'text'. Try patindex()
declare @txt varchar(100)
set @txt ='Te33 Text CD789 Te6t'
select substring(@txt,patindex('%[A-Z][A-Z][0-9][0-9][0-9]%', @txt),5)
Rgds
Serg
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply