Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to get all null values column in a table

Author  Topic 

dhani
Posting Yak Master

132 Posts

Posted - 2009-07-23 : 12:23:55

Hello All,

i have a table with 67 columns, is there any way to get the columns that are having all null values in it

in detail: i have a table called userStatisticsTemp it has around 67 columns some of the columns has all null values , some of them were having both null as well as values & some other has just values
so is there a any trick to know what columns has all null values rather than select each column in where clause condition


Thanks in advance
Best Regards
Dhani

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2009-07-23 : 12:33:48
SELECT SUM(CASE when COLUMN_NAME is null THEN 0 Else 1 End) as NumberNonNullRecords FROM YOUR_TABLE
Go to Top of Page
   

- Advertisement -