USE AdventureWorksOBP CREATE or ALTER TRIGGER trDrzavaInsert ON Drzava AFTER INSERT,DELETE,UPDATE AS SELECT * FROM inserted SELECT * FROM Drzava SELECT * FROM deleted UPDATE Drzava SET Naziv='UK' WHERE Naziv='UUK' SELECT TOP 3 * FROM Kupac GO DECLARE @Ime NVARCHAR(50) SELECT @Ime = Ime FROM Kupac WHERE IDKupac=9821 PRINT @Ime GO DROP TRIGGER trDrzavaInsert PRINT @Ime DECLARE @Varijabla NVARCHAR(50) SET @Varijabla = 'Štefica' SELECT @Varijabla as Varijabla DECLARE @Prodano BIGINT SET @Prodano = (select sum(Kolicina) from stavka) SELECT @Prodano as Prodano DECLARE @NazivProizvoda NVARCHAR(50) DECLARE @BojaProizvoda NVARCHAR(50) SELECT @NazivProizvoda = p.Naziv, @BojaProizvoda = p.Boja FROM Proizvod as p where p.IDProizvod=741 SELECT @NazivProizvoda AS Naziv SELECT @BojaProizvoda AS Boja IF @BojaProizvoda = 'Srebrna' BEGIN PRINT @BojaProizvoda END ELSE IF @BojaProizvoda = 'Crna' BEGIN PRINT @NazivProizvoda END CREATE TRIGGER trDrzavaInsert ON Drzava AFTER INSERT AS DECLARE @NovaDrzava NVARCHAR(50) DECLARE @InsertedID INT SELECT @InsertedID = IDDrzava, @InsertedID = Naziv FROM inserted PRINT 'Upisana je nova država: ' + @NovaDrzava + ', IDDrzava:'+(CAST(@InsertedID AS NVARCHAR(5))) INSERT INTO Drzava SELECT * FROM Grad CREATE TABLE Zapisnik( IDGrad INT, Naziv NVARCHAR(150) ) CREATE TRIGGER trGradInsertCopy ON Grad AFTER INSERT AS INSERT INTO Zapisnik (IDGrad, Naziv) SELECT IDGrad, Naziv FROM inserted INSERT INTO Grad(Naziv) VALUES ('Beč') SELECT * FROM Zapisnik