How to find the Table which has Maximum Columns in a database

If you are interested to know about the table (in a particular database) that has most number of columns and how many columns.. You can run the below script..

SELECT NAME AS Table_Name, max_column_id_used AS Total_Columns
From SYS.tables
WHERE max_column_id_used =
(SELECT MAX(max_column_id_used) FROM SYS.tables)

As shown in the below screen shot, it will list the table and the number of columns in that table..

Table_with_Max_Columns

Do you like this site? Like our FB page @ Facebook.com\LearnSQLWithBru so that, you know when there is a new blog post.

–Bru Medishetty

Leave a Reply