SQL Server › Views

Can you insert, update, or delete data through a view, and what conditions must be met for this to work?

Beginner

Answer

You can modify data through a view as long as it references only a single underlying table and does not include certain features like GROUP BY, DISTINCT, or aggregate functions, since SQL Server needs to be able to clearly translate your change back to the correct row in the actual underlying table.
CREATE VIEW SimpleCustomerView AS
SELECT CustomerId, Name, Email FROM Customers;

UPDATE SimpleCustomerView SET Email = 'new@example.com' WHERE CustomerId = 123;
Real-world example A support application updates a customer's email address through a simple view rather than the underlying table directly, which works correctly since the view is based on a single table without any aggregation or complex logic.

Common follow-ups: What specific features in a view definition prevent it from being updatable?;Is it generally considered good practice to modify data through a view?