-- SYNTAX
CREATE VIEW vViewName
AS
SELECT-STATEMENT
WITH CHECK OPTION;
IF OBJECT_ID
('dbo.vProductNumLike_BE', 'view') IS NOT NULL
DROP VIEW dbo.vProductNumLike_BE ;
CREATE VIEW dbo.vProductNumLike_BE
AS
SELECT *
FROM Production.Product
WHERE ProductNumber like 'BE%'
WITH CHECK OPTION
GO
INSERT INTO vProductNumLike_BE (
Name,
ProductNumber,
StandardCost,
ListPrice,
SafetyStockLevel,
ReorderPoint,
DaysToManufacture,
SellStartDate
)
VALUES ('product-1', 'AR-737',
0.00,0.00, 500,750, 3, GETDATE())
-- Insertion fails because the view will now
-- only accept ProductNumber starting with BE