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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Return Field names where Field values are not null

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-04-20 : 10:04:39
Jonathan writes "I need to return the field names of an SQL table where there is one or more non null value in the field. eg.

if i have :

field1 field2 field3
1 <null> 1
2 <null> 2
3 <null> <null>

then i only want to return the names of field1 and field3, which may be Title, Surname for example.

Hope you can help

Jonathan"

X002548
Not Just a Number

15586 Posts

Posted - 2004-04-20 : 12:43:57
Column Names?

What do you mean?



Brett

8-)
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2004-04-20 : 18:57:30
the quickest way might be to look at it like this:

select min(city) as city, min(state) as state, min(address1) as Address1, ...
from tbl

anywhere you see a null in a particular column in the 1 row resultset returned, you know you have null value(s) in there ...

- Jeff
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2004-04-21 : 09:35:22
Jeff,

I'm guessing they're asking for column names....



Brett

8-)
Go to Top of Page
   

- Advertisement -