select SORT_ORDER = case type when 'C' then 60 when 'D' then 30 when 'F' then 40 when 'FN' then 100 when 'IF' then 100 when 'K' then 50 when 'P' then 90 when 'S' then 70 when 'TF' then 100 when 'TR' then 20 when 'U' then 10 when 'V' then 80 else 110 end, TYPE = case type when 'C' then 'check constraints' when 'D' then 'defaults' when 'F' then 'foreign keys' when 'FN' then 'functions' when 'IF' then 'functions' when 'K' then 'primary keys' when 'P' then 'stored procedures' when 'S' then 'system tables' when 'TF' then 'functions' when 'TR' then 'triggers' when 'U' then 'user tables' when 'V' then 'views' else type end, QTY = count(1) from sysobjects group by case type when 'C' then 60 when 'D' then 30 when 'F' then 40 when 'FN' then 100 when 'IF' then 100 when 'K' then 50 when 'P' then 90 when 'S' then 70 when 'TF' then 100 when 'TR' then 20 when 'U' then 10 when 'V' then 80 else 110 end, case type when 'C' then 'check constraints' when 'D' then 'defaults' when 'F' then 'foreign keys' when 'FN' then 'functions' when 'IF' then 'functions' when 'K' then 'primary keys' when 'P' then 'stored procedures' when 'S' then 'system tables' when 'TF' then 'functions' when 'TR' then 'triggers' when 'U' then 'user tables' when 'V' then 'views' else type end order by 1