|
Posted by Erland Sommarskog on 10/02/60 11:45
pb648174 (google@webpaul.net) writes:
> Ok, does running the below once per week seem reasonable for a SQL 2005
> DB?
Some small modifications:
> DECLARE TableCursor CURSOR FOR
> SELECT top 1 table_name FROM information_schema.tables
1) The TOP 1 should probably not be there.
2) Change "table_name" to quotename(table_name), so you can defrag
Northwind and its Order Details too. :-)
3) And change to correct case, in case you one day want to run it on
case-sensitive database. It's INFORMATION_SCHEMA etc.
And I will have to admit that I have not really digested the new
ALTER INDEX syntax in SQL 2005, but I guess that part looks find.
--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
Navigation:
[Reply to this message]
|