Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- USE НАЗВАНИЕБАЗЫ
- GO
- EXEC sp_MSforeachtable @command1="print '?' DBCC DBREINDEX ('?', ' ', 80)"
- GO
- EXEC sp_updatestats
- GO
- USE
- GO
- CREATE PROCEDURE spUtil_ReIndexDatabase_UpdateStats
- AS
- DECLARE @MyTable VARCHAR(255)
- DECLARE myCursor
- CURSOR FOR
- SELECT '['+TABLE_SCHEMA+'].['+TABLE_NAME+']'
- FROM information_schema.tables
- WHERE table_type = 'base table'
- OPEN myCursor
- FETCH NEXT
- FROM myCursor INTO @MyTable
- WHILE @@FETCH_STATUS = 0
- BEGIN
- PRINT 'Reindexing Table: ' + @MyTable
- DBCC DBREINDEX(@MyTable, '', 80)
- FETCH NEXT
- FROM myCursor INTO @MyTable
- END
- CLOSE myCursor
- DEALLOCATE myCursor
- EXEC sp_updatestats
- GO
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement