Advertisement
swlsi

Untitled

Jul 19th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.57 KB | None | 0 0
  1. USE Gastro1 --Enter the name of the database you want to reindex
  2.  
  3.  
  4.  
  5. DECLARE @TableName varchar(255)
  6.  
  7.  
  8.  
  9. DECLARE TableCursor CURSOR FOR
  10.  
  11. SELECT table_name FROM information_schema.tables
  12.  
  13. WHERE table_type = 'base table'
  14.  
  15.  
  16.  
  17. OPEN TableCursor
  18.  
  19.  
  20.  
  21. FETCH NEXT FROM TableCursor INTO @TableName
  22.  
  23. WHILE @@FETCH_STATUS = 0
  24.  
  25. BEGIN
  26.  
  27. DBCC DBREINDEX(@TableName,' ',90)
  28. --SELECT @TableName
  29. FETCH NEXT FROM TableCursor INTO @TableName
  30.  
  31. END
  32.  
  33.  
  34.  
  35. CLOSE TableCursor
  36.  
  37.  
  38.  
  39. DEALLOCATE TableCursor  
  40. GO  
  41. EXEC sp_updatestats;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement