Tuesday, June 9, 2009

Recreate Index

DECLARE @TabName varchar(100)
Declare @T1 varchar(100)
DECLARE Recreateindex CURSOR FOR select table_name from information_schema.tables OPEN Recreateindex
FETCH NEXT FROM Recreateindex INTO @TabName
WHILE @@FETCH_STATUS = 0
BEGIN
set @t1=@TabName
DBCC DBREINDEX (@T1)
-- print
Fetch NEXT FROM Recreateindex INTO @TabName
END
CLOSE Recreateindex
DEALLOCATE Recreateindex

No comments:

Post a Comment