• Well just change the @counting in the select to your table name

    The table variable and insert is to create a testing environment using readily consumable data which someone can just pick up and generate a solution. It is part of the forum etiquette when posting T-SQL questions to provide this information. Take a look in the second link in my signature, and it should explain more as to why I have done that bit of code.