I want to replace PH0100000 by string but only in the first tab like PH01000000 to string0 PH01000001 to string1 .... PH01278104 to string278104 PH01278028 to string278028
I want it to look like string0G0240 P.he_genemodel_v1.0 CDS 120721 121773 . - . ID=PH01000000G0240.CDS;Parent=PH01000000G0240 string1G0190 P.he_genemodel_v1.0 mRA 136867 137309 . - . ID=PH01000001G0190.mRNA;Parent=PH01000001G0190 .............................................
Ah.. what I posted will remove the part before the first tab.
When you want to replace, what is the rule that you want to use? It seems like you want to have a fixed length to the number that is appended? For example PH01278104 --> string278104. Why is the 01 omitted? Is it because you want to keep only six digits, or is it something else?
I want to replace PH0100000 by string but only in the first tab like PH01000000 to string0 PH01000001 to string1 .... PH01278104 to string278104 PH01278028 to string278028
"stringvalue" is the format i need. so i have to remove the PH01 from all entries but if used replace PH01 for all entries PH01000000 beocmes string00000 instead of string0. I hope i am not confusing.
DECLARE @tab TABLE( col VARCHAR(30)) insert into @tab SELECT 'PH01000000G0240' UNION ALL -- String0G0240 SELECT 'PH01000001G0190' UNION ALL -- String1G0190 SELECT 'PH01278104G0010' UNION ALL String278104G0010 SELECT 'PH01278028G0210' --String278028G0210
SELECT 'String' +CAST(CAST(SUBSTRING(col, 5, 6) AS INT) AS VARCHAR(10))+ RIGHT(col, 5) FROM @tab