My task is to analyze a big table (250 columns, millions of rows). I need to find out, how many defined values (e.g. -1) there are in each column. I have a solution that loops through the columns of my table and uses the methods described in the following links:
Fastest way to count exact number of rows in a very large table?
However, I have to do:
select column into #tab from MyBigTable where column = -1
And then apply the methods to #tab.
Do you see any way how this can be efficiently dealt with?