I've fortunately never had the "pleasure" of working with SAP but this M3 system is not all bad. They do at least use their design philosophy pretty consistently throughout the application, despite how hard it must be to maintain logic in over 3300 tables which are ALL named in 6 characters and some of them being over 250 columns wide (yes, the column names are also all 6 characters). Did I mention that 32 of these tables have a 16-column clustered index? I actually made a query for fun to see the number of columns in the clustered indexes:with cte as ( select distinct TableName = OBJECT_NAME(ic.OBJECT_ID), ColumnName = COL_NAME(ic.OBJECT_ID,ic.column_id) FROM sys.indexes AS i INNER JOIN sys.index_columns AS ic ON i.OBJECT_ID = ic.OBJECT_ID AND i.index_id = ic.index_id WHERE i.index_id = 1),cte2 as ( select TableName, ColumnsInClusteredIndex = count(*), RowNum = ROW_NUMBER() OVER (ORDER BY TableName) from cte group by TableName ),cte3 as ( select TotalCount = count(*) from cte2)select ColumnsInClusteredIndex, TablesCount = count(*), TotalCount, Percentage = CONVERT(decimal(5, 2), ((count(*)*1.0) / TotalCount) * 100)from cte2 cross join cte3group by ColumnsInClusteredIndex, TotalCountorder by ColumnsInClusteredIndex desc
And the result? ->ColumnsInClusteredIndex TablesCount TotalCount Percentage16 32 3327 0.9615 15 3327 0.4514 23 3327 0.6913 33 3327 0.9912 38 3327 1.1411 66 3327 1.9810 69 3327 2.079 105 3327 3.168 165 3327 4.967 245 3327 7.366 322 3327 9.685 458 3327 13.774 535 3327 16.083 631 3327 18.972 407 3327 12.231 183 3327 5.50
- LumbagoMy blog-> http://thefirstsql.com