Link to home
Start Free TrialLog in
Avatar of Mackey_man
Mackey_manFlag for Sweden

asked on

Display columns with no values in table, select count(*)

I have a table with 250 columns and 10 000 000 rows. I want to display all the columns that doesn't have  a value except for the default value.

I'm looping through the syscolumns for the table SalesTransactions by using select count like below, I'm checking what data type it is and I have different conditions for each column type. (Int and varchar in this example)

SELECT COUNT(*) From SalesTransactions WHERE CustomerNo >0

SELECT COUNT(*) From SalesTransactions WHERE CustomerName <>''

This works fine on table with not so many rows. Is there a more efficient way to count rows than using select count(*) for each column ?

I don't care to know the exact numer of rows, I'd rather just display columns that doesn't have values.

Any suggestions ?


ASKER CERTIFIED SOLUTION
Avatar of sshah254
sshah254

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of blandyuk
blandyuk
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mackey_man

ASKER

Thanks guys for trying to help me, I just have to let my procedure run and just use it on tables less rows.