Skip to content

Commit a31c77f

Browse files
Update AzureSQLMaintenance.txt
2017-12-12: fix total indexes reported to the output window. functionality was not impacted by this issue.
1 parent 38ce61f commit a31c77f

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

AzureSQLMaintenance.txt

+14-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22
/* This script provided AS IS, Please review the code before executing this on production environment */
33
/* For any issue or suggestion please email to: [email protected] */
44

5+
6+
/*
7+
***********************************************
8+
Current Version Date: 2017-12-12
9+
***********************************************
10+
11+
Change Log:
12+
2017-12-12: fix total indexes reported to the output window. functionality was not impacted by this issue.
13+
14+
*/
15+
516
if object_id('AzureSQLMaintenance') is null
617
exec('create procedure AzureSQLMaintenance as /*dummy procedure body*/ select 1;')
718
GO
@@ -104,15 +115,15 @@ begin
104115
raiserror('Index Information:',0,0) with nowait
105116
raiserror('---------------------------------------',0,0) with nowait
106117

107-
select @msg = count(*) from #idxBefore where index_id in (1,2)
118+
select @msg = count(*) from #idxBefore
108119
set @msg = 'Total Indexes: ' + @msg
109120
raiserror(@msg,0,0) with nowait
110121

111-
select @msg = avg(avg_fragmentation_in_percent) from #idxBefore where index_id in (1,2) and page_count>@minPageCountForIndex
122+
select @msg = avg(avg_fragmentation_in_percent) from #idxBefore where page_count>@minPageCountForIndex
112123
set @msg = 'Average Fragmentation: ' + @msg
113124
raiserror(@msg,0,0) with nowait
114125

115-
select @msg = sum(iif(avg_fragmentation_in_percent>=5 and page_count>@minPageCountForIndex,1,0)) from #idxBefore where index_id in (1,2)
126+
select @msg = sum(iif(avg_fragmentation_in_percent>=5 and page_count>@minPageCountForIndex,1,0)) from #idxBefore
116127
set @msg = 'Fragmented Indexes: ' + @msg
117128
raiserror(@msg,0,0) with nowait
118129

0 commit comments

Comments
 (0)