Create Procedure spMatchQuantityAndPercentage
@MatchInventoryQuantity nvarchar(10),
@Percentage decimal (3,2)
AS
BEGIN
BEGIN TRY
INSERT INTO Sales.SpecialOffer(SpecialOfferID, Description, DiscountPct, Type, Category,
StartDate, EndDate, MinQty, MaxQty, ModifiedDate)
VALUES('18', 'Discount on products with quantity greater than the
matched inventories','0.50','Greater than match quantity', 'Customer', '2019-11-01 00:00:00',
'2019-11-02 00:00:00', '0', NULL, '2019-11-02 00:00:00');
INSERT INTO Sales.SpecialOfferProduct (SpecialOfferID, ProductID)
SELECT DISTINCT 18, PP.ProductID
FROM Production.ProductInventory as PP
Group By PP.ProductID
Having SUM(Quantity) > @MatchInventoryQuantity
END TRY
BEGIN CATCH
PRINT 'The error was handled'
END CATCH
END
I am trying to create a discount and assign all products with a total inventory quantity (product is not unique in inventory) greater then the match quantity to that special offer, making sure to assign the product only once.
How do I assign these parameters of percentage(discount)
and specialofferID
not as constants as used in the insert state and select statements above?