I wrote a script that checks a column for a name/number combo, when found it creates the next entry by incrementing the number. It works fine and I have my example below.
Example: I query and get
abc-qwert01
abc-qwert02
my script inserts the next entry of.
abc-qwert02
The problem I have is that even though the strings are unique, some have text after the number and it breaks my where clause.
Example:
SELECT * FROM TABLE WHERE column LIKE 'abc-qwert%'
returns
abc-qwert01
abc-qwert02
abc-qwert01dv
abc-qwert02dv
abc-qwert03dv
abc-qwert04dv
Then my insert puts in abc-qwert05 when it should be abc-qwert03.
My query needs to be able to select all of the ‘abc-qwert%’ or ‘abc-qwert%%dv’, its the ones that have a suffix that i am having a hard time trying to figure out.
I have tried charindex, potindex and even though i can get the slice of the string, how can I query for all of the strings that have a suffix?
abc-qwert01dv
1