473,402 Members | 2,064 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Check null values for more than one column

rsrinivasan
221 100+
Hi all,

I have one table with 24 fields in SQL server.
In this some of the fields has NULL value.
But i want to get the records which does not have any NULL value in any one of the fields.
This is my Query:
Expand|Select|Wrap|Line Numbers
  1. select * from tablename
  2. where  v1  is not null and v2  is not null and  
  3. v3  is not null and v4  is not null and  
  4. v5  is not null and v6  is not null and
  5. v7  is not null and v8  is not null and
  6. v9  is not null and v10 is not null and
  7. v11 is not null and v12 is not null and
  8. v13 is not null and v14 is not null and
  9. v15 is not null and v16 is not null and
  10. v17 is not null and v18 is not null and
  11. v19 is not null and v20 is not null and
  12. v21 is not null and v22 is not null and
  13. v23 is not null and v24 is not null
Is it correct? Or can i use some other method. Because i have millions of records in this table.
Jun 6 '08 #1
4 4002
I think that's the only way; below is a variation I actually to check records with no null values using ISNULL.

SELECT * FROM tablename
WHERE ISNULL(v1 + v2 + v3 + v4 + v5 + v6 + ... + v24,'n') <> 'n'

If anything inside is null it treats the whole thing as null.

where n are the fields you want to check for null values
All the fields I check are varchar fields, but I think you would have to use cast or ocnvert for nonvarchar fields (if you use 'n' as the null value)

Thanks,

Zach
Jun 8 '08 #2
ck9663
2,878 Expert 2GB
That would depend on the setting of SET CONCAT_NULL_YIELDS_NULL. For more details read this

-- CK
Jun 9 '08 #3
r035198x
13,262 8TB
If you are using some front-end language you could shorten the code by creating that query using a loop.
Jun 9 '08 #4
loora
1
i have the same issue
would u please explained to me the deatil expression of isNull function in oracle or if any one has other way to create query to check null values for more than one column where the both of the column has number value.
i faced error when i write the where statement as follow:
select column1, column2
from table
where coulmn1 and coulmn2 is not null;
May 9 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

26
by: Agoston Bejo | last post by:
I want to enforce such a constraint on a column that would ensure that the values be all unique, but this wouldn't apply to NULL values. (I.e. there may be more than one NULL value in the column.)...
0
by: Alex82 | last post by:
I can't use it....for example i have to create a column that accept values between 1 to 120...i can't enumerate all of them....or i have to accept a value different from NULL if an other column has...
3
by: A.M. de Jong | last post by:
Reading a lot about Nulls right now I still can't find a Technical reason to use it or not. For what I've understand is this: In an Ingres database a Null column has a standard extra storage...
3
by: iStrain | last post by:
Hiya. I'm _sure_ this is an FAQ, but Googling hasn't produced the answer in a way I can make sense out of. I know I should get this, but so far no way... I'm creating tables and doing queries in...
1
by: sianan | last post by:
I tried to use the following example, to add a checkbox column to a DataGrid in an ASP.NET application: http://www.codeproject.com/aspnet/datagridcheckbox.asp For some reason, I simply CAN'T get...
9
by: Edmund Dengler | last post by:
Greetings! Just trying some tests out, and wanted to know about some optimizations. If I do a CHECK constraint on a table, is this used to optimize a SELECT or does Postgresql rely mostly on...
1
by: Daniel Martini | last post by:
Hi all, I'm currently coding some functions in plpgsql for generating reports out of records in a table. Problem is: NULL values in records make the complete function fail. Here is a simple...
6
by: Susanne Klemm | last post by:
Hi! I have a table with a check constraint. But unfortunately it does not work like I wanted. CREATE TABLE MAP ( NOT NULL, NULL,
3
by: ferg | last post by:
I have a Customer table. The table has two different CHECK constraints. Then there is the Customer details dialog, which provides the user with an UI for changing users. I have some UPDATE sql,...
9
by: =?Utf-8?B?UGV0ZXJX?= | last post by:
I have a TabControl on a Windows form in which I have various tab pages each with a DataGridView, the first column of which is a DataGridViewCheckBoxColumn and subsequent columns being...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.