Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Databases use indexes on tables to locate data quickly.  If there are large changes in data or volumes of data over time - or if the database is moved to another SQL Server, maintenance may be required on the indexes. 

Panelcode
bgColorlanguage#fffsql
titleRebuild database indexesIndexes
DECLARE @TableName VARCHAR(255)
DECLARE @sql NVARCHAR(500)

DECLARE TableCursor CURSOR FOR
SELECT OBJECT_SCHEMA_NAME([object_id])+'.['+ name +']' AS TableName
FROM sys.tables

OPEN TableCursor
FETCH NEXT FROM TableCursor INTO @TableName
WHILE @@FETCH_STATUS = 0
BEGIN
	SET @sql = 'ALTER INDEX ALL ON ' + @TableName + ' REBUILD'
print (@sql)
	EXEC (@sql)
	FETCH NEXT FROM TableCursor INTO @TableName
END
CLOSE TableCursor
DEALLOCATE TableCursor
GO

 

Filter by label (Content by label)
showLabelsfalse
max5
spacesJ7UG
showSpacefalse
sortmodified
reversetrue
typepage
cqllabel in ("sqlserver","performance","tuning") and type = "page" and space = "J7UG"
labelsperformance sqlserver tuning

...