I’ve run into a DB that has tables that are excessively wide. (600+ columns) Even asking for the top 100 rows with no parameters takes 4 seconds. I’d like to slim these tables down a bit.
To figure out which columns can be most easily moved to new tables, or removed entirely, I would like to know how many nulls are in each column. This should tell me what information is likely to be least important.
How would I write a query that can find all columns and count the nulls inside those columns?
Edit The DB is SQL server 2008. I’m really hoping not to type each of the columns individually. It looks like sys.columns could help with this?
Edit2 The columns are all different types.
Try this