• To add to Gail's reply, the optimizer parses the literal values in the IN predicate and extracts unique values.

    Here's an example using your code:

    DECLARE @T TABLE (

    Column1 int,

    Column2 int

    )

    INSERT INTO @T VALUES(1,2),(2,3),(3,4),(4,5),(5,6),(6,7),(7,8),(8,9)

    SELECT *

    FROM @T

    WHERE Column2 IN (1, 2, 2, 3, 4, 5, 5, 5, 6, 6, 7, 8, 8, 8, 8, 8)

    The scan predicate found in the execution plan is the following:

    Predicate: [Column2]=(1) OR [Column2]=(2) OR [Column2]=(3) OR [Column2]=(4) OR [Column2]=(5) OR [Column2]=(6) OR [Column2]=(7) OR [Column2]=(8)

    However, this is just an implementation detail you shouldn't care about.

    EDIT: typo

    -- Gianluca Sartori