清理索引碎片.sql 424 B

12345678910111213141516171819202122
  1. DECLARE @name varchar(100)
  2. DECLARE authors_cursor CURSOR FOR
  3. SELECT table_schema + '.' + table_name as [name]
  4. FROM information_schema.tables
  5. WHERE table_type = 'base table'
  6. OPEN authors_cursor
  7. FETCH NEXT FROM authors_cursor INTO @name
  8. WHILE @@FETCH_STATUS = 0
  9. BEGIN
  10. DBCC DBREINDEX (@name, '', 90)
  11. FETCH NEXT FROM authors_cursor
  12. INTO @name
  13. END
  14. deallocate authors_cursor