|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Thursday, January 29, 2009 6:50 PM
Points: 31,
Visits: 2
|
|
|
|
|
|
SSC Eights!
      
Group: General Forum Members
Last Login: Wednesday, May 09, 2012 10:26 AM
Points: 891,
Visits: 1,958
|
|
I would suggest two changes where you declare the cursor:
declare db cursor for select name from master.dbo.sysdatabases where name not in ('master','tempdb') and charindex('-',name) = 0 and version <> 0
Checking the version prevents trying to reindex an offline database, the charindex prevents processing of databases that contain a dash in their name: the code would otherwise fail. This is for SQL Server 2000, I'm not sure if it would be implemented the same way in later versions.
|
|
|
|