• tilew-948340 (3/12/2012)


    I am not sure to understand perfectly the WITH CHECK option.

    Put simply, WITH CHECK means that rows that are inserted or updated through the view must still satisfy the view's predicate. In other words, if you do an insert or update through the view and then a select immediately after it, you should see the updated or inserted row.

    Example:

    CREATE VIEW SalesPpl

    AS

    SELECT EmpNo, Name, Salary, Department

    FROM Personnel

    WHERE Department IN ('Sales', 'SalesBackOffice');

    The view above allows people to add personnel into the Marketing department, or to update a row to transfer someone from Sales to Accounting. The WITH CHECK option prevents that, while still allowing users to update a row to transfer people between Sales and SalesBackOffice.


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/