Thank you very much, Palmen, it works.
I worked with 2000 before, but new to SQL 2005. I am not aware you can have SQL script starts with 'WITH'?, is this new feature in 2005? Would the same script work with 2000? Please enlighten me. Thanks.
The "With" is a CTE: http://msdn.microsoft.com/en-us/library/ms190766.aspx
It will not work in SQL Server 2000.
Phil Brammer | http://www.ssistalk.com | Twitter: http://twitter.com/PhilBrammer