• The case statement will assign 'FF' to @str6 ,Remaining varaibles contains NULL values by default and not assigned with corresponding values of AA,BB,CC,DD and EE. The values are assigned to variables after completion loop.

    It looked like variables overwrite to me... and I didn't see any reference suggesting otherwise.

    At the start of the loop , @str1 is assigned a value AA , and then with the next cycle gets assigned to NULL . At the end of the loop all ,@STR* , becomes NULL but @str6; it is FF and didn't get to see the next loop.

    In the next loop, it gets interesting, as the NULLIF and ISNULL comes into the use; the result output becomes constant for string @cmpstr ,i.e. FF until any number of loop execution.

    ~ demonfox
    ___________________________________________________________________
    Wondering what I would do next , when I am done with this one :ermm: