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 |
|
memento
Starting Member
16 Posts |
Posted - 2006-06-09 : 11:19:48
|
| I was wondering if any of you knows of a simple way to select the name of the columns that have null values in a row of a table. |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
memento
Starting Member
16 Posts |
Posted - 2006-06-09 : 14:05:10
|
| Doesn't that return the columns that can hold null values, ie that don't have NOT NULL ?What I'm trying to find is, in a record, what attributes are null (in that particular moment). |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2006-06-09 : 14:30:41
|
quote: Originally posted by memento Doesn't that return the columns that can hold null values, ie that don't have NOT NULL ?What I'm trying to find is, in a record, what attributes are null (in that particular moment).
select column_namefrom my_tablewhere column_name is nullCODO ERGO SUM |
 |
|
|
memento
Starting Member
16 Posts |
Posted - 2006-06-09 : 14:42:30
|
| For instanceid |Name| Car nr | Boat nr | plane nr1 Joe 23 null null2 Jane null 1 22I want to have a select that finds what transports Joe doesn't have, so in this case it would return "boat nr" and "plane nr".In the general solution, I want to find what transports people don't have at that time. |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2006-06-09 : 17:36:36
|
| [code]select Name, [Null transport] = 'Boat nr'from my_tablewhere [Boat nr] is nullunion allselect Name, [Null transport] = 'plane nr'from my_tablewhere [plane nr] is null[/code]CODO ERGO SUM |
 |
|
|
|
|
|