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.
Author |
Topic |
-Dman100-
Posting Yak Master
210 Posts |
Posted - 2014-02-23 : 12:50:59
|
Is it possible to replace a string value that uses a wildcard? For example, I'm trying to update a field on a table and replace the field value where it starts with a specific two character pattern and remove it from the string. The field is a delimited string and I want to replace any occurrence of ;A0% or ;A0* with a null value. I don't want to replace the entire field with a null value.Let's say my field value is this:;00236;08231;06106 Washington DC;06106 CCA Wash DC;05120;A0106; I want the result to be this:;00236;08231;06106 Washington DC;06106 CCA Wash DC;05120; I was trying several variations:UPDATE myTable SET myField = REPLACE(myField,'XX%','')Any help is appreciated.Thanks |
|
nagino
Yak Posting Veteran
75 Posts |
Posted - 2014-02-23 : 18:41:15
|
Wildcard can use LIKE clause or some function.Like following.UPDATE myTableSET myField = LEFT(myField, PATINDEX('%;A0%', myField))WHERE myField LIKE '%;A0%'-------------------------------------From JapanSorry, my English ability is limited. |
|
|
|
|
|