Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

check whether a series is valid or not

$
0
0
Hi, I have a scenario in which I have to check that whether I am correct no of series or not...

Createtable tbl(  ID intidentity,number varchar(10),numstatus varchar(10))INSERTINTO tblValues('V001','Active'),('V002','Active'),('V003','Active'),('V004','InActive'),('V005','Active')

I tried in this manner....
Declare @firstno varchar(10)='V0001',           @scndno varchar(10)='V0005'Createtable #voucherno(	voucherno varchar(10))INSERTINTO #vouchernoSELECT VoucherNo from tbl WHERE number between @firstno and @scndno SELECT gv.numberFROM   tbl  As gv INNERJOIN #voucherno ro ON ro.VoucherNo = gv.numberWHERE  gv.numstatus ='Active'

AS values that i passed in parameters @frstno and @scndno is not in series as v004 is inactive so I should get message invalid series....
My query gives me output as V001,v002,V003,v005. I tried with IF EXISTS but didnt get desired output

Please Mark as Answer if my post works for you or Vote as Helpful if it helps you. Kapil Singh


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>