我有两个观点,如下面
create view penord1_view
as
select
ser, docno, pcode, barcode, pname, unid, unit, qty, rate
from
sale
where
tc = 'O01' and docdt > @xdate1 and docdt < @xdate2
union
select
sser as ser, sdocno as docno, pcode, barcode, pname, unid, unit, qty, rate
from
sale
where
tc = 'P01' and docdt > @xdate1 and docdt < @xdate2
,第二个是
create view penord_view
as
select
ser, docno, pcode, barcode, pname, unid, unit, rate,
SUM(qty) AS qty
from
penord1_view
group by
ser, docno, pcode, barcode, pname, unid, unit, rate
问题是我无法在第一个视图中传递@xdate1
参数。
请在SQL Server
中以视图或其他方式建议如何执行此操作答案 0 :(得分:1)
根据定义,视图没有参数。您可以将其视为已保存的查询。如果您想使用参数,您应该考虑使用存储过程。