In a Select statement, I need to strip leading and trailing commas from one column. It has values like:
,,Value1,Value2,,,,
There are no spaces between the commas.
I have tried using CharIndex to find the first occurrence of [a-zA-Z] but I don't know how to make that work.
Here's an example of my Code:
Select CustID, SaleDate, TargetColumn, CharINDEX('a-z', TargetColumn) [Position]
Every row in the [Position] column returns a 0.
I was hoping to be able to locate the first and last instance of [a-zA-Z] and then remove everything before and after those positions, respectively.
I appreciate that this may have been asked before, but I was not able to find tsql code that I can use in a Select statement.
I'd appreciate any help/pointers.
Thanks!