DROP table tbl
CREATE TABLE tbl
(ID int identity, Voucherno varchar(10), numstatus varchar(10)
)
INSERT INTO tbl VALUES
('V0001','Active'),
('V0002','Active'),
('V0003','Active'),
('V0004','InActive'),
('V0005','Active')
DECLARE @firstno varchar(10) = 'V0001',
@scndno varchar(10) = 'V0005'
SELECT Voucherno
FROM tbl
WHERE Voucherno BETWEEN @firstno AND @scndno
AND NOT EXISTS (
SELECT 1
FROM tbl
WHERE Voucherno BETWEEN @firstno AND @scndno
AND numstatus = 'InActive')
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden