Skip to content

Instantly share code, notes, and snippets.

@GuyHarwood
Created May 11, 2013 08:06
Show Gist options
  • Save GuyHarwood/5559269 to your computer and use it in GitHub Desktop.
Save GuyHarwood/5559269 to your computer and use it in GitHub Desktop.
Reindex Azure SQL Database
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
exec('ALTER INDEX ALL ON ' + @TableName + ' REBUILD')
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