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
 General SQL Server Forums
 New to SQL Server Programming
 detecting if at least one column has a NULL

Author  Topic 

tariq2
Posting Yak Master

125 Posts

Posted - 2011-11-07 : 11:11:23
Hi,

Thank you in advance..
I have a table with 20 columns...
I need to genarate rows which fulfill the condition
that any of tHE columns have a NULL.

Is there a quicker way than writing
the statement with 20 ORs:

select * from D_Clients where ParentKey is NULL or ParentName IS NULL


Thank you

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-11-07 : 11:16:45
if all are of same datatype you can use

select * from D_Clients where ParentKey + ParentName +.... IS NULL

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

tariq2
Posting Yak Master

125 Posts

Posted - 2011-11-09 : 10:29:52
Thank you Visakh :)
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-11-09 : 11:19:37
wc

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -