Advertisement
Guest User

Untitled

a guest
Dec 16th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. USE НАЗВАНИЕБАЗЫ
  2. GO
  3. EXEC sp_MSforeachtable @command1="print '?' DBCC DBREINDEX ('?', ' ', 80)"
  4. GO
  5. EXEC sp_updatestats
  6. GO
  7.  
  8. USE
  9. GO
  10. CREATE PROCEDURE spUtil_ReIndexDatabase_UpdateStats
  11. AS
  12. DECLARE @MyTable VARCHAR(255)
  13. DECLARE myCursor
  14. CURSOR FOR
  15. SELECT '['+TABLE_SCHEMA+'].['+TABLE_NAME+']'
  16. FROM information_schema.tables
  17. WHERE table_type = 'base table'
  18. OPEN myCursor
  19. FETCH NEXT
  20. FROM myCursor INTO @MyTable
  21. WHILE @@FETCH_STATUS = 0
  22. BEGIN
  23. PRINT 'Reindexing Table: ' + @MyTable
  24. DBCC DBREINDEX(@MyTable, '', 80)
  25. FETCH NEXT
  26. FROM myCursor INTO @MyTable
  27. END
  28. CLOSE myCursor
  29. DEALLOCATE myCursor
  30. EXEC sp_updatestats
  31. GO
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement