• Got it right, but I think the answer should be "it depends". On what? The selectivity of the data in Col. You get a seek if you populate your table thus:

    INSERT INTO TestTable (id, col)

    SELECT TOP 1000000 ROW_NUMBER() OVER (ORDER BY a.name),

    'name' + CAST(ROW_NUMBER() OVER (ORDER BY a.name) AS varchar(7))

    FROM master.sys.columns a

    CROSS JOIN master.sys.columns b

    CROSS JOIN master.sys.columns c

    ... but a scan if you have the following data in the table:

    INSERT INTO TestTable (id, col)

    SELECT TOP 1000000 ROW_NUMBER() OVER (ORDER BY a.name),

    'name' + CAST((ROW_NUMBER() OVER (ORDER BY a.name))/500000 AS char(5))

    FROM master.sys.columns a

    CROSS JOIN master.sys.columns b

    CROSS JOIN master.sys.columns c

    Therefore, in the second case, there'd be no way of optimising the stored procedure.

    John