Advertisement
piotrek77

TRIGGER CDN.TwrKarty_SED_KategoriaABC ON CDN.TwrKarty

Oct 30th, 2012
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 1.58 KB | None | 0 0
  1. -- ================================================
  2. -- Template generated from Template Explorer using:
  3. -- Create Trigger (New Menu).SQL
  4. --
  5. -- Use the Specify Values for Template Parameters
  6. -- command (Ctrl-Shift-M) to fill in the parameter
  7. -- values below.
  8. --
  9. -- See additional Create Trigger templates for more
  10. -- examples of different Trigger statements.
  11. --
  12. -- This block of comments will not be included in
  13. -- the definition of the function.
  14. -- ================================================
  15. SET ANSI_NULLS ON
  16. GO
  17. SET QUOTED_IDENTIFIER ON
  18. GO
  19. -- =============================================
  20. -- Author:      Piotr Oslowski
  21. -- Create date: 2012-10-30
  22. -- Description: <Description,,>
  23. -- =============================================
  24. CREATE TRIGGER CDN.TwrKarty_SED_KategoriaABC
  25.    ON  CDN.TwrKarty
  26.    AFTER UPDATE
  27. AS
  28. BEGIN
  29.     -- SET NOCOUNT ON added to prevent extra result sets from
  30.     -- interfering with SELECT statements.
  31.     SET NOCOUNT ON;
  32.    
  33.    
  34.     if Update(twr_wartosc2)
  35.     Begin
  36.    
  37.    
  38.    
  39.    
  40.  
  41.      
  42.             update cdn.twrkarty
  43.             set twr_kategoriaabcxyz=left(twr_wartosc2,1) from cdn.twrkarty
  44.            
  45.             where twr_wartosc2 in ('a','b','c','d')
  46.             AND twr_GIDNumer in (SELECT Twr_GIDNUmer from inserted)
  47.            
  48.            
  49.             update cdn.twrparmag
  50.             set tpm_kategoriaabcxyz=left(twr_wartosc2,1), TpM_TStampM = dateDiff(SECOND, '19900101', getdate()) from cdn.twrparmag
  51.             join cdn.twrkarty on twr_gidnumer=tpm_twrnumer
  52.             where  twr_wartosc2 in ('a','b','c','d')
  53.             AND Twr_GIDNumer in (SELECT Twr_GIDNumer from inserted)
  54.      
  55.    
  56.  
  57.  
  58.  
  59.     End
  60.     -- Insert statements for trigger here
  61.  
  62. END
  63. GO
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement