If you use the >=
and <
operators you can return the required range by increasing"increasing the second argumentargument" by 1. Technically, replacing the last character ('5'
) with the next character ('6'
) in the character set.
Below is a query that returns all the rows in your range of A010
and A025
. To get this I pass 'A026'
as the second argument. The expression < 'A026'
includes the value 'A0259456546'
.
DECLARE @Test TABLE
(
Val NVARCHAR(100)
) ;
INSERT @Test
VALUES ('A0004534543'),
('A01034950834'),
('A020043553'),
('A0259456546'),
('A0264565464') ;
SELECT *
FROM @Test
WHERE Val >= 'A010'
AND Val < 'A026' ;