Here's the code we use:SET NOCOUNT ONDECLARE @dbName sysname, @rc int, @sql nvarchar(4000)SELECT nameINTO #dbFROM sys.databasesWHERE name NOT IN ('master', 'model', 'msdb', 'tempdb', 'Admin', 'DBA', 'OnePoint') AND name NOT LIKE '%ReportServer%' AND DATABASEPROPERTYEX([name], 'IsInStandBy') = 0 AND DATABASEPROPERTYEX([name], 'Status') = 'ONLINE' AND DATABASEPROPERTYEX([name], 'Updateability') = 'READ_WRITE' AND source_database_id IS NULLSET @rc = @@ROWCOUNTSELECT @dbName = MIN(name)FROM #dbWHILE @rc <> 0BEGIN SET @sql = 'EXEC ' + QUOTENAME(@dbName) + '.dbo.sp_updatestats @resample = ''resample''' EXEC (@sql) SELECT TOP 1 @dbName = name FROM #db WHERE name > @dbName ORDER BY name SET @rc = @@ROWCOUNTENDDROP TABLE #db
Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Subscribe to my blog