Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE VIEW dbo.uvw_StockingDays
- AS
- SELECT ItemNmbr
- , ItemDesc
- , dbo.ufn_SplitGet(USCATVLS_1, '-', 1) AS MinDays -- custom function that splits the text on '-' and returns the first index
- , dbo.ufn_SplitGet(USCATVLS_1, '-', 2) AS MaxDays
- FROM IV00101
- GO
- CREATE TRIGGER dbo.upd_StockingDays
- ON uvw_StockingDays
- INSTEAD OF UPDATE AS
- IF (COLUMNS_UPDATED() & 12) > 0 -- the last two columns
- UPDATE IV00101
- SET USCATVLS_1 = MinDays + '-' + MaxDays -- invalid column names
- WHERE IV00101.ItemNmbr = ItemNmbr -- want to refer to view's itemnmbr
- GO
Advertisement
Add Comment
Please, Sign In to add comment