October 15, 2004 at 12:08 pm
is there a script or command out there that will run sp_statistics against all the indexes in all the tables of a certain database?
October 18, 2004 at 7:22 am
MS_foreachtable will run a command against all tables. Might be a way to script it for all indexes.
October 18, 2004 at 8:51 am
DECLARE cur_Databases
CURSOR FOR
SELECT CATALOG_NAME
FROM INFORMATION_SCHEMA.SCHEMATA
WHERE CATALOG_NAME NOT IN ('master', 'msdb', 'tempdb', 'model', 'pubs', 'Northwind')
DECLARE @DbName VARCHAR(50)
DECLARE @Buildstring VARCHAR(100)
OPEN cur_Databases
FETCH NEXT
FROM cur_Databases
INTO @DbName
WHILE @@FETCH_STATUS = 0
BEGIN
SET @Buildstring = 'EXEC ' + @DbName + '..sp_updatestats'
EXEC (@Buildstring)
FETCH NEXT
FROM cur_Databases
INTO @DbName
END
CLOSE cur_Databases
DEALLOCATE cur_Databases
Give that a go
Wes
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply