Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL-server-2005
actually I am working in c# and sql2005
in query,am getting lot of null values. means there are some columns containing null values in each row.
i just want to ignore that column. means i want to show all columns containing values.
 
please advice
Thanks in Advance
Posted 25-Aug-11 22:01pm
Edited 25-Aug-11 22:05pm
Prerak Patel140.7K
v2
Comments
Sangunni at 26-Aug-11 4:48am
   
Could you please elaborate more with an example ?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

SELECT Col1, Col2, Col3 
FROM Table1
WHERE (Col1 IS NOT NULL)
AND (Col2 IS NOT NULL)
AND (Col3 IS NOT NULL)
  Permalink  
Comments
RaisKazi at 26-Aug-11 8:58am
   
My 5.
djj55 at 26-Aug-11 10:15am
   
This will show only rows where all three columns have non null values. If you want rows that have one or two non null values use OR instead of AND.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

you can try following LINQ query:
 
var a = from p in obj.tableName where p.Col1 != null && p.Col2 != null select p;
 
If you are going through SQL query only then uper sollution is fine.
 
-Sagar Solanki
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

SELECT *
FROM Table1
WHERE Col1 IS NOT NULL
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web03 | 2.8.150327.1 | Last Updated 26 Aug 2011
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100