我正在尝试创建一个在执行时具有日期参数的存储过程。我希望能够搜索在特定日期之间发货的订单。我有这个:
create procedure sp_orders_by_dates
@startdate smalldatetime,
@enddate smalldatetime
as
select OrderID,
o.CustomerID,
c.CompanyName as CustomerCompany,
s.ShipperID,
s.CompanyName as ShipperCompany,
ShippedDate
from Orders o join Customers c
on o.CustomerID = c.CustomerID join Shippers s
on s.ShipperID = o.ShipperID
where @startdate = ShippedDate,
@enddate = ShippedDate
order by ShippedDate
并执行,我必须这样做:
EXEC sp_orders_by_dates '1991-07-01', '1991-08-31'
我知道这部分出了什么问题,但我只是不知道如何在这里制作“介于”声明:
where @startdate = ShippedDate,
@enddate = ShippedDate