DROP VIEW vGradoviDrzave CREATE VIEW vGradoviDrzave AS SELECT g.IDGrad, g.Naziv as Grad, g.DrzavaID, d.IDDrzava, d.Naziv as Drzava FROM Grad as g LEFT JOIN Drzava as d ON g.DrzavaID = d.IDDrzava ALTER VIEW vGradoviDrzave AS SELECT g.IDGrad, g.Naziv as Grad, g.DrzavaID, d.IDDrzava, d.Naziv as Drzava FROM Grad as g LEFT JOIN Drzava as d ON d.IDDrzava = g.DrzavaID SELECT * FROM vGradoviDrzave SELECT SCOPE_IDENTITY() INSERT INTO vGradoviDrzave (Drzava, DrzavaID) VALUES ('Madarska', SCOPE_IDENTITY()) CREATE OR ALTER VIEW vGradoviDrzave WITH SCHEMABINDING, ENCRYPTION AS SELECT g.IDGrad, g.Naziv as Grad, g.DrzavaID, d.IDDrzava, d.Naziv as Drzava FROM dbo.Grad as g INNER JOIN dbo.Drzava as d ON g.DrzavaID = d.IDDrzava WHERE DrzavaID = 1 WITH CHECK OPTION UPDATE vGradoviDrzave SET DrzavaID=2 WHERE IDGrad=5 UPDATE Grad SET DrzavaID=1 WHERE IDGrad=5 INSERT INTO vGradoviDrzave (Grad, DrzavaID) VALUES ('Varazdin', 2) CREATE OR ALTER VIEW vKreditneKartice AS SELECT * FROM KreditnaKartica as kk WHERE kk.Tip = 'Visa' OR kk.Tip = 'MasterCard' WITH CHECK OPTION INSERT INTO vKreditneKartice (Tip, Broj, IstekGodina, IstekMjesec) VALUES ('American Express', '11111111111111', 2006, 9) SELECT * FROM vKreditneKartice WHERE Broj = '11111111111111'