Add statements at the top to select your database
USE [DATABASE]
GO
Save and run the script in the query analyzer. I have used this in SQL Server 2008, 2008R2 and 2012. I have no reason to believe it won't work in 2005 or even 2000, but I have not tested it in those environments.
Running on a Windows 7 Developer box against a 2008 R2 server it took about 43 sections to generate a 25-year table.