Morning!
This is more of a "how can this be better" question, as to my knowledge the query below functions as expected.
Overall, I am trying to make a query (TSQL allowed) that takes a user input value (@Input) and sees if it exists in dbo.Table, ignoring prefix characters.
e.g. T.Value = FOOBAR
@Input = FOOBAR (true)
@Input = AFOOBAR (true)
@Input = FOORBARA (false)
@Input = FFOOBAR (true)
@Input = FOOBARR(false)
@Input = F (false)
etc..
Fairly confident the below works, however, I wanted to get other opinions as I am curious if a better/more efficient solution exists.
SELECT *
FROM dbo.Table AS T
WHERE CHARINDEX(REVERSE(T.Value), @Input, 0) > 0
AND @Input LIKE REVERSE(T.Value) + '%'
Thanks,