IF EXISTS ( SELECT *
FROM INFORMATION_SCHEMA.ROUTINES WHERE SPECIFIC_SCHEMA = N'dbo'
AND SPECIFIC_NAME = N'Reports'
AND ROUTINE_TYPE = N'PROCEDURE')
DROP PROCEDURE dbo.Reports
GO
CREATE PROCEDURE dbo.Reports (@Date_of_Purchase DATE)
AS
BEGIN
SELECT o.O_Id, o.Sale_Price, o.Private_Band, c.Type, c.Points_Issued, o.Date_of_Purchase
FROM Order_Details o
LEFT JOIN Transaction_Historys c ON o.Date_of_Purchase = c.Date_of_Purchase
WHERE o.Date_of_Purchase > @Date_of_purchase
END
GO
EXECUTE dbo.Reports
GO
我想做o.Date_of_Purchase > DATEADD(d,@date,getdate())
。@date
应该是基于用户输入的动态值,如何@date
动态声明 days()。
执行存储过程时出现错误:
必须声明标量变量