I often run into small, annoying little problems as I'm sure most people working in IT do at some point, so I decided to start blogging the solutions. No matter how insignificant they may seem, they may save someone an hour or two of Google'ing for the answer.
How to: Reindex an entire database on SQL Server 2000 or SQL Server 2005 in a single statement:
EXEC [sp_MSforeachtable] @command1="DBCC DBREINDEX('?')"
If you want to receive progress messages while it is running, try this version:
EXEC [sp_MSforeachtable] @command1="RAISERROR('DBCC DBREINDEX(''?'') ...',10,1) WITH NOWAIT DBCC DBREINDEX('?')"