this is my first time posting so hopefully I get all the information needed across correctly.
I'm attempting to do an update replace statement on a row where there is a set of characters but a wildcard statement won't work, below is a select statement example
SELECT replace(column, '[aA][bB][cC]-', '')
FROM table
where column like '%[aA][bB][cC]-%'
an example row would be "abc-123 aBc-123 abC-abc Def-123", but I need it to return "123 123 abc"
this is a basic example, but I'm trying to get rid of a set of 3 characters and a "-" character anywhere in a string. the abc could change to def but the "-" character will always come after.
I've done some googling and can't find an appropriate solution as most examples will only remove one example of abc- where I need to get rid of all versions. I'm running version 12.0 of sql server (SQL Server 2014) so I think some functions I wouldn't be able to use.
I think the closest example I could find was Using Wildcard For Range of Characters In T-SQL but I can't use the translate function.
Edit: below is an example of a created table
CREATE TABLE String_Removal_Example(
someValue VARCHAR(100)
)
INSERT INTO String_Removal_Example (someValue) VALUES ('abc-123')
INSERT INTO String_Removal_Example (someValue) VALUES ('abc-123 ABC-123')
INSERT INTO String_Removal_Example (someValue) VALUES ('abc-123 ABc-123 123-ABC DEF-123')
select statement brings back
someValue
abc-123
abc-123 ABC-123
abc-123 ABc-123 123-ABC DEF-123
Edit2: If this isn't possible to do in this manner, a possible alternative would be to remove 3 characters and the - character. I've tried the below
select Substring (someValue, Charindex( '-', someValue ) + 1, Len(someValue)) From String_Removal_Example
but this returns the below, which is only affecting the first instance of nnn-.
123
123 ABC-123
123 ABc-123 123-ABC DEF-123
Edit3: The string I need to replace is nnn- for clarification. I was trying for the [aA][bB][cC]- format in case I needed to change it. It will always be 3 characters followed by a "-" Character