Identify Tables with Large Column Counts

You can identify tables with a huge column count in the following way:

DECLARE @limit INT;SET @limit = 30; --MAX 30 Columns;WITH c([object_id], [column count]) AS(  SELECT [object_id], COUNT(*)    FROM sys.columns    GROUP BY [object_id]    HAVING COUNT(*)  @limit)SELECT [table] = + N'.' +,    c.[column count]  FROM c  INNER JOIN sys.tables AS t  ON c.[object_id] = t.[object_id]  INNER JOIN sys.schemas AS s  ON t.[schema_id] = s.[schema_id]  ORDER BY c.[column count] DESC; 
Share the Post:
Share on facebook
Share on twitter
Share on linkedin


Recent Articles: