I am struggling to find any documentation on how SQL Server actually stores a non-persisted computed column.
Take the following example:
--SCHEMA CREATE TABLE dbo.Invoice ( InvoiceID INT IDENTITY(1, 1) PRIMARY KEY, CustomerID INT FOREIGN KEY REFERENCES dbo.Customer(CustomerID), InvoiceStatus NVARCHAR(50) NOT NULL, InvoiceStatusID AS CASE InvoiceStatus WHEN 'Sent' THEN 1 WHEN 'Complete' THEN 2 WHEN 'Received' THEN 3 END ) GO --INDEX CREATE NONCLUSTERED INDEX IX_Invoice ON Invoice ( CustomerID ASC ) INCLUDE ( InvoiceStatusID ) GO
I get that it is stored at the leaf level, but if the value is not persisted how is anything stored at all? How does the index help SQL Server find these rows in this situation?
Any help greatly appreciated,
Thanks to Brent & Aaron for answering this, here's the PasteThePlan clearly showing what they explained.