我有一个这样的存储过程:
alter procedure [dbo].[carcallvalidation]
@carid nvarchar(100)=null
as
begin
select count(t.TBarcode) as barcodeCount, t.Paid,t.Status,t.DelDate
from Transaction_tbl t
where TBarcode=@carid
group by t.paid,t.status,t.DelDate
declare @transid integer=null;
select @transid= t1.transactID from Transaction_tbl t1 where TBarcode=@carid;
if(select count(k.transactid) from KHanger_tbl k where k.transactid=@transid)>0
begin
return 1
end
end
如果我传递carid
了错误的数字,则返回一个空表;但我希望它改为T.Barcode
计数为 0。
我怎样才能做到这一点?