Skip to content

Instantly share code, notes, and snippets.

@smarenich
Created July 12, 2016 04:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smarenich/34c2f719ef92a2dc5b658422c2d5a5a9 to your computer and use it in GitHub Desktop.
Save smarenich/34c2f719ef92a2dc5b658422c2d5a5a9 to your computer and use it in GitHub Desktop.
DECLARE @TableName varchar(255)
DECLARE TableCursor CURSOR FOR
SELECT table_name FROM information_schema.tables
WHERE table_type = 'base table'
OPEN TableCursor
FETCH NEXT FROM TableCursor INTO @TableName
WHILE @@FETCH_STATUS = 0
BEGIN
DBCC DBREINDEX(@TableName,' ',90)
FETCH NEXT FROM TableCursor INTO @TableName
END
CLOSE TableCursor
DEALLOCATE TableCursor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment