SQL Server passing [value%] to parameter in crystal report

cuxqih21  于 2023-04-04  发布在  其他
关注(0)|答案(2)|浏览(142)

dear all I tried to add query into crystal report command the query is

Declare @FromDate Datetime
Declare @ToDate Datetime
Declare @Whse nvarchar(10)
 select @FromDate = min(S0.Docdate) from dbo.OINM S0 where S0.Docdate >={?@FromDate}
 select @ToDate = max(S1.Docdate) from dbo.OINM s1 where S1.Docdate <={?@ToDate}
select @Whse = Max(s2.Warehouse) from dbo.OINM S2 Where S2.Warehouse ='[%2]'
Select @Whse as 'Warehouse', a.Itemcode, max(a.Dscription) as ItemName,
sum(a.OpeningBalance) as OpeningBalance, sum(a.INq) as 'IN', sum(a.OUT) as OUT,
...

the original query is

...select @FromDate = min(S0.Docdate) from dbo.OINM S0 where S0.Docdate >='[%0]'
 select @ToDate = max(S1.Docdate) from dbo.OINM s1 where S1.Docdate <='[%1]'
select @Whse = Max(s2.Warehouse) from dbo.OINM S2 Where S2.Warehouse ='[%2]'

I changed '[%0] to be >={?@FromDate} (parameter) and it is work fine the same for '[%1]' now I can't change '[%2]' the only thing work with me is to change it into {?@Whse} but this give me wrong data in the report

regards

sqxo8psd

sqxo8psd1#

I'm not clear whats are you trying to obtain from the where clause, but if you're trying to obtain those warehouse with the text: 2% you can try like??

Try these:

select @Whse = Max(s2.Warehouse) from dbo.OINM S2 Where S2.Warehouse Like '%2'
7vux5j2d

7vux5j2d2#

change it to

select @Whse = Max(s2.Warehouse) from dbo.OINM S2 Where S2.Warehouse ={?@select*from OWHS}

its work fine but for if you select more than one warehouse you will have error

相关问题