You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-- Find non-zero fill factors for identity columns (set back to 100)
2
+
-- Part of the SQL Server DBA Toolbox at https://github.com/DavidSchanzer/Sql-Server-DBA-Toolbox
3
+
-- This script lists identity columns that have a FILLFACTOR value that is neither 0 nor 100, and provides the ALTER INDEX statement to fix it.
4
+
1
5
EXEC dbo.sp_ineachdb @command ='
2
-
SELECT OBJECT_NAME(i.object_id) AS TableName, i.name AS index_name, COL_NAME(ic.object_id, ic.column_id) AS column_name, ''ALTER INDEX ['' + i.NAME + ''] ON ['' + OBJECT_NAME(i.object_id) + ''] REBUILD WITH (SORT_IN_TEMPDB = OFF, ONLINE = ON, FILLFACTOR = 100)'' AS RebuildSQL
3
-
FROM sys.indexes AS i
4
-
INNER JOIN sys.index_columns AS ic ON i.object_id = ic.object_id
5
-
AND i.index_id = ic.index_id
6
-
INNER JOIN sys.columns AS c ON c.object_id = ic.object_id
7
-
AND c.column_id = ic.column_id
8
-
WHERE i.fill_factor != 0
9
-
AND c.is_identity = 1;
6
+
SELECT OBJECT_NAME(i.object_id) AS TableName,
7
+
i.name AS index_name,
8
+
COL_NAME(ic.object_id, ic.column_id) AS column_name,
9
+
i.fill_factor AS fill_factor,
10
+
''ALTER INDEX ['' + i.name + ''] ON ['' + OBJECT_NAME(i.object_id)
11
+
+ ''] REBUILD WITH (SORT_IN_TEMPDB = OFF, ONLINE = ON, FILLFACTOR = 100)'' AS RebuildSQL
EXEC dbo.sp_ineachdb @command ='SELECT ''?'' AS DatabaseName, OBJECT_NAME(object_id) AS TableName, name AS IndexName, fill_factor FROM sys.indexes WHERE fill_factor != 0';
1
+
-- Find non-zero fill factors
2
+
-- Part of the SQL Server DBA Toolbox at https://github.com/DavidSchanzer/Sql-Server-DBA-Toolbox
3
+
-- This script finds all indexes that have a fill factor that is neither 0 nor 100
0 commit comments