Not sure of your complete data format. To the provided sample, the below would work for you.
Create Table Test_Oct_31_1(Col1 Varchar(50))
Insert into Test_Oct_31_1 Select 'PF-India-QP-9-02396'
Insert into Test_Oct_31_1 Select 'PF-India-9-0026'
Insert into Test_Oct_31_1 Select 'PF-India-QP-9-0044'
Select PARSENAME(REPLACE(REPLACE(REPLACE(Col1,'-India-QP-','I-QP-'),'-India-9-','I-STD-9-'),'-','.'),2) +'-'
+ PARSENAME(REPLACE(REPLACE(REPLACE(Col1,'-India-QP-','I-QP-'),'-India-9-','I-STD-9-'),'-','.'),4) +'-'
+ PARSENAME(REPLACE(REPLACE(REPLACE(Col1,'-India-QP-','I-QP-'),'-India-9-','I-STD-9-'),'-','.'),3) +'-'
+ PARSENAME(REPLACE(REPLACE(REPLACE(Col1,'-India-QP-','I-QP-'),'-India-9-','I-STD-9-'),'-','.'),1)
From Test_Oct_31_1
Drop table Test_Oct_31_1
Please use Marked as Answer if my post solved your problem and use Vote As Helpful if a post was useful.
No comments:
Post a Comment