LiveSqlHelp (8/31/2013)
I would avoid the loop, create a temp table named #temp and insert the values of the Years from 2000 to 2010.
And you would do that without a loop ....
Note there is no join in the second query, it works by FM (Freaking Magic)
No magic, just a cartesian product.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability