Krishna Teja Krishna Teja - 2 months ago 6
SQL Question

How to find a string in between two varchar strings in SQL server?

Consider below table, I should be able to get result as "A" when input any value between XYZ-00000001 and XYZ-00000005 for eg: XYZ-00000003 or XYZ-00000004

similarly when input is given as XYZ-00000008 value "B" should be resulted.

Table

Answer
SELECT [NAME] FROM YourTable WHERE YourValue BETWEEN Val1 AND Val2
Comments