|
|
Cry How to...Run dbcc checkdb on each database (using cursors)The simplest way to run '
The disadvantage of this approach is that the script needs to be updated each time a new database is added or a database deleted. It is also unlikely to be portable from one server to another without being rewritten. An alternate and more adaptable approach is to let the script determine what databases are present and to run dbcc checkdb on each in turn:
The advantage of this approach is that the script does not need updating should a new database be added or one removed and it can be copied from one server to another and executed without change. These notes have been tested against SQL Server 7, SQL Server 2000 and SQL Server 2005. |