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)
 Finding attributes with NULLs

Author  Topic 

dmilam
Posting Yak Master

185 Posts

Posted - 2010-10-18 : 15:29:09
How to find all attributes in a database which contain NULL? -- (not a count of all NULLs, just the attribute names are wanted)

In other words, those which are not merely nullable, but have a NULL "value"

So not merely:


SELECT name as [column_name]
FROM sys.all_columns
where is_nullable = 1


tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-10-18 : 15:40:42
You can play around with this:
select 'select count(*) as ' + column_name + ' from ' + table_name
from information_schema.columns
where is_nullable = 'YES'

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

dmilam
Posting Yak Master

185 Posts

Posted - 2010-10-18 : 15:47:24
Thanks!
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-10-18 : 15:57:44
You're welcome, glad to help.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -