jeudi 24 septembre 2015

SQL Server Compare data and replaced together

I have two string as below

 ***ABCABCABCABCABC***
 BBBTTTTTTTTTTTTTTTCCC

I want to replace * position only from below string

So results could be

 BBBABCABCABCABCABCCCC
 BBBTTTTTTTTTTTTTTTCCC

Is there any way to have elegant solution to using SQL Server function?

I already did it using below.

 DECLARE @Value1=PATINDEX('%[A,C,G,T]%', '***ABCABCABCABCABC***')
 Select SUBSTRING('BBBTTTTTTTTTTTTTTTBBB', 0, @Value1)
 ....

But this is required many if eles .

I want to know is there any simple way to replace it or not.

Thank you!

Aucun commentaire:

Enregistrer un commentaire