• Took some time to interpret the question, but eventually got that correct. The key to answer is to visualize how the data gets stored in table variable. Like for the first few iterations (3 iterations shown below), data would look like

    ----------------------

    | IASINT | IASSTRING |

    ----------------------

    | 1 | 1 |

    | 2 | 1 |

    | 2 | 2 |

    | 3 | 2 |

    | 3 | 3 |

    | 4 | 3 |

    ----------------------

    Now for statement "SET @x = ??? --set an integer value between 1 and 19", we try to imagine the output of the two statements (summary given below)

    When

    @X = 1; "statement 1" will return 1 row and "statement 2" will return 2 rows

    @X = 2; "statement 1" will return 3 rows and "statement 2" will return 2 rows

    @X = 3; "statement 1" will return 3 rows and "statement 2" will return 4 rows

    @X = 4; "statement 1" will return 5 rows and "statement 2" will return 4 rows

    Hence, Statement 1 only returns more rows than Statement 2 when @X is even.

    Nice Qotd Ron 🙂

    ~ Lokesh Vij


    Guidelines for quicker answers on T-SQL question[/url]
    Guidelines for answers on Performance questions

    Link to my Blog Post --> www.SQLPathy.com[/url]

    Follow me @Twitter