I need assistance creating a while loop that will loop through all the records in my table variable.
There are a few approaches, depending on your ultimate goal.
First, as JohnM said in his comment, look for a set based solution, you may not need a while loop at all.
If you must use a while loop, but you will only use that table variable to fuelt hat one while loop, you can have it loop while there are rows in the table, select one row, and then delete that row at the end of the loop.
Another way is to add a row-number column to the table variable and then use a counter. The counter will identify the row to select next and give you the conditional to find that row from the table and the loop can be set to terminate when your counter exceeds the number of rows in the table.
And finally (and this is probably the worst option, but for completeness....) you could use a cursor.
answered May 03 '12 at 04:43 PM