Reputation: 21187
I have a table of allowed formats that I need to be able to lookup based on a string. Some example formats are:
I need to return one or more matching rows based on a sample input of:
Unfortunately the character '^' is fixed as the wildcard, this is a constraint I can't change.
I was hoping that perhaps regex could save me here, maybe using the format as the pattern and comparing it to the input. Regex is not something I have used much in the past so I'm not really sure of its capabilities. Failing that, is there any other way of performing this lookup?
Upvotes: 1
Views: 185
Reputation: 56735
Like this:
SELECT *
FROM yourTable
WHERE @INPUT LIKE REPLACE(yourTable.savedFormat, '^', '%')
This won't allow you to leverage any indexs on your savedFormat column, but I suspect thats hopeless anyway for these requirements.
Upvotes: 1