I need to code a for next loop in a SQL stored procedure. I tried joining multiple SELECT statements together but the length of the string is greater then 8000. Basically the SELECT statement returns the same 3 values, only the where clause changes. Looking for a value equal to an specific number that is then incremented 10 times, ie WHERE ItemCount = 10, WHERE ItemCount = 11 etc. Looking to loop and increcment the value. I am assignng the results to a temp table and then retreiveing them at the end of the process.
If it is possible what is the syntax?