infogulch

Untitled

Mar 15th, 2012
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.57 KB | None | 0 0
  1. CREATE VIEW dbo.uvw_StockingDays
  2. AS
  3. SELECT ItemNmbr
  4.      , ItemDesc
  5.      , dbo.ufn_SplitGet(USCATVLS_1, '-', 1) AS MinDays -- custom function that splits the text on '-' and returns the first index
  6.      , dbo.ufn_SplitGet(USCATVLS_1, '-', 2) AS MaxDays
  7. FROM IV00101
  8. GO
  9.  
  10. CREATE TRIGGER dbo.upd_StockingDays
  11. ON uvw_StockingDays
  12. INSTEAD OF UPDATE AS
  13. IF (COLUMNS_UPDATED() & 12) > 0 -- the last two columns
  14.     UPDATE IV00101
  15.     SET USCATVLS_1 = MinDays + '-' + MaxDays -- invalid column names
  16.     WHERE IV00101.ItemNmbr = ItemNmbr -- want to refer to view's itemnmbr
  17. GO
Advertisement
Add Comment
Please, Sign In to add comment