microsoft / tigertoolbox

Toolbox repository for Tiger team
http://aka.ms/sqlserverteam
Other
1.45k stars 734 forks source link

Index-Information - KeyCols_data_length_bytes also aggregates for included columns #291

Open BobbyH49 opened 1 year ago

BobbyH49 commented 1 year ago

Line 678 in view_IndexInformation.sql and line 698 for view_IndexInformation_CurrentDB.sql are aggregating for Key and included columns. Adding "and sic.is_included_column = 0" into the WHERE clause for the "KeyCols_data_length_bytes" column will stop the aggregation from picking up included columns.

BobbyH49 commented 1 year ago

Also, why does KeyCols_data_length_bytes have a case statement checking for nvarchar and then dividing by 2? The key length value is in bytes not characters. The case statement can be removed.