Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

Creating a trigger on a sql view with filters

$
0
0

So what i am wanting to accomplish is for the data to be copied to a specific table once an item arrives from the view when the deliverydate is set.

CREATE TRIGGER [dbo].[Inventory_PO_Items_Automate_Inventory]
ON [dbo].Inventory_PO_Items ---View
AFTER UPDATE
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
IF Inventory_PO_Items.ItemClass = 'Office Supplies' and Inventory_PO_Items.descript is not null and Inventory_PO_Items.DeliveryDate is not null

Insert into Consumable_Log -- Table that that keeps track of when office supplies come in or taken out
(Site_Purchased,SKU, DateChanged, PO, Quantity_Added, [Description], Cost)
Select Vendor, Item, DeliveryDate, Po, Quantity, Descript, Price
From [Inventory_PO_Items]

Else If Inventory_PO_Items.ItemClass = 'Promtional...


Viewing all articles
Browse latest Browse all 4871

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>