View with NOEXPAND
View with NOEXPAND is a SQL statement in the Views category. SQL Server: prevents the optimizer from expanding the view into its base query. Forces indexed view use. The syntax is SELECT * FROM view_name WITH (NOEXPAND);. It returns indexed view result. A typical example: CREATE VIEW vw_sales_summary WITH SCHEMABINDING AS SELECT product_id, SUM(qty) AS total_qty, COUNT_BIG(*) AS cnt FROM dbo.order_items GROUP BY product_id; CREATE UNIQUE CLUSTERED INDEX idx ON vw_sales_summary (product_id); -- Without NOEXPAND, optimizer may expand the view SELECT * FROM vw_sales_summary WITH (NOEXPAND) WHERE product_id = 100; -- Forces use of the indexed view (much faster) -- Available in: SQL Server Enterprise/Developer editions A close relative is CREATE VIEW, which creates a virtual table based on a SELECT query. Think of it as a saved query that acts like a table. A close relative is DROP VIEW, which removes a view from the database. Does not affect the underlying tables.