• Lowell (1/24/2013)


    i thought it was clear: i read it as howard saying there is no need to mark an calculated column as persisted in order to index it...it's not a requirement.

    simple example:

    --drop table products

    CREATE TABLE Products(

    id INT IDENTITY(1, 1) NOT NULL PRIMARY KEY,

    pname VARCHAR(30),

    CostPerItem MONEY,

    ItemsPerCase INT,

    ValuePerCase AS CostPerItem * ItemsPerCase

    )

    INSERT INTO Products

    SELECT 'Bananas',.49,40 UNION ALL

    SELECT 'Apples',.49,36 UNION ALL

    SELECT 'Pineapples',3.49,5

    SELECT * FROM Products where ValuePerCase > 18

    CREATE INDEX IX_Product_ValuePerCase ON Products(ValuePerCase)

    SELECT * FROM Products where ValuePerCase > 18

    Seems an odd way to read it in context here, since the OP stated in his original post that he could index a computed column w/o explicitly persisting it. I guess I just didn't understand why that needed to be restated separately.

    SQL DBA,SQL Server MVP(07, 08, 09) A socialist is someone who will give you the shirt off *someone else's* back.