I'm trying to put together a sproc to feed a crystal report, but i can't get the report to return any records. I'm assuming because it's reading a null value in the parameter as just that. Here's my Sproc:
create PROC dbo.ACCR_RECEIPTS
@vendorname varchar(50),
@PONumber varchar(50)
AS
Select c.EDFPONUMBER, c.[idfRCVDetailKey],b.vendname,a.idftransactiontype,
c.idfqtyinvoiced, c.idfqtyshipped, c.edfprice,
(c.idfqtyinvoiced * c.edfprice) as [Extended Inv Amt], (c.idfqtyshipped * c.edfprice) as [Extended Rcv Amt],
a.idftransactiontype, c.edfPOline, c.edfponumber
from [CA].[dbo].[RCVHeader] A
left outer join CA.dbo.PM00200 B
on a.edfvendor = b.vendorid
inner join [CA].[dbo].[RCVDetail] C
on a.idfrcvheaderkey = c.idfrcvheaderkey
where a.idftransactiontype between 1 and 2 and b.vendname= isnull(@vendorname, b.vendname) and c.edfponumber=isnull(@PONumber,c.edfponumber)
I want people to be able to enter a specific PO number OR Vendor name, but if they leave it blank they get all values. I've seen a few ways to handle this, and none of them seem to work. any thoughts?
create PROC dbo.ACCR_RECEIPTS
@vendorname varchar(50),
@PONumber varchar(50)
AS
Select c.EDFPONUMBER, c.[idfRCVDetailKey],b.vendname,a.idftransactiontype,
c.idfqtyinvoiced, c.idfqtyshipped, c.edfprice,
(c.idfqtyinvoiced * c.edfprice) as [Extended Inv Amt], (c.idfqtyshipped * c.edfprice) as [Extended Rcv Amt],
a.idftransactiontype, c.edfPOline, c.edfponumber
from [CA].[dbo].[RCVHeader] A
left outer join CA.dbo.PM00200 B
on a.edfvendor = b.vendorid
inner join [CA].[dbo].[RCVDetail] C
on a.idfrcvheaderkey = c.idfrcvheaderkey
where a.idftransactiontype between 1 and 2 and b.vendname= isnull(@vendorname, b.vendname) and c.edfponumber=isnull(@PONumber,c.edfponumber)
I want people to be able to enter a specific PO number OR Vendor name, but if they leave it blank they get all values. I've seen a few ways to handle this, and none of them seem to work. any thoughts?