Regarding the temptable: I use the @toggle flag to determine if the temptable is already created or not.
In the first loop, @toggle=0 and a "select into" is used to create the table. @toggle is also set to 1
In the next loops, @toggle=1, resulting in an "insert into"
If you want to be sure this table doesn't exist, add this code before the cursor declaration:
drop table #db03632
Regarding the "Strange characters": that's a result of different charactersets
. As suggested, copy code into an editor and remove the goofy characters
WilfredThe best things in life are the simple things