• One minor issue with your code you don't seem to be incrementing the @I counter so it will run indefincately (possibly a cut/paste error)

    The problem you will have is that after the first run your results will be skewed, ad the cache will have been warned, by the previous execution, so you could see a significant drop in the performance and so over a thousand runs you will experience a false positive.

    One way round that would be to 'vary' the Input parameter, in order to replicate the true running of the SP, unless every execution will have the same value.

    This will cause a more natural view of how performant the SP is.

    It wouldn't take much to do , simply create a table with 10 values and then use a Mod 10 to get the value for that run.

    the other issue you will have with the STATISTICS is that they will produce data for each statement after they are switched on, and it can be confusing when trawling through a complex SP to see which Stat relates to which part of the code.

    Hope this helps.

    _________________________________________________________________________
    SSC Guide to Posting and Best Practices