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.
Author |
Topic |
jcnewman83
Starting Member
6 Posts |
Posted - 2011-02-02 : 16:01:37
|
HI,I need some help with a Select statement.I have a table that looks similar to the belowName Code Data1 Data1 Data3Fred A123 ghghg ftftft gygygyBill A456 hghhh hyupuAnn A789 hghghgSarah A012 ghtsa What I want is a select statement that will return all rows in this table where there is no data in the Data 1,2 and 3 columns, so basically what I would want to see returned is:Name Code Data1 Data1 Data3Bill A456 hghhh hyupuAnn A789 hghghgSarah A012 ghtsa can someone help get me on the correct path on this one??Thanks in advance for anyone's help. |
|
srujanavinnakota
Starting Member
34 Posts |
Posted - 2011-02-02 : 17:14:10
|
Try this..Select * FROM yourTable WHERE (Data1='' OR Data1 is null) UNION Select * FROM yourTable WHERE (Data2='' OR Data2 is null)UNION Select * FROM yourTable WHERE (Data3='' OR Data3 is null) |
 |
|
Ranjit.ileni
Posting Yak Master
183 Posts |
Posted - 2011-02-02 : 23:28:54
|
Try this ..select * from [yourtable]where Data1 is null or Data2 is null or Data3 is nullIRK |
 |
|
jcnewman83
Starting Member
6 Posts |
Posted - 2011-02-03 : 06:28:06
|
This worked like a charm, thank you.quote: Originally posted by srujanavinnakota Try this..Select * FROM yourTable WHERE (Data1='' OR Data1 is null) UNION Select * FROM yourTable WHERE (Data2='' OR Data2 is null)UNION Select * FROM yourTable WHERE (Data3='' OR Data3 is null)
|
 |
|
|
|
|