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
 General SQL Server Forums
 New to SQL Server Programming
 how to select not null values

Author  Topic 

born2acheive
Yak Posting Veteran

65 Posts

Posted - 2006-10-04 : 06:04:56
hi, i have 5 columns in my table

name age phone sex salary

dani 21 1233 m

see this output, there salary is null.
actually i want to use * (ie)
select * from emp, if i use this the following output has to come

name age phone sex

dani 21 1233 m

becos there is no value in salary column.
so please tall me how to do this,please give me query to do this.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-10-04 : 06:07:40
if you use select * from table it will return all columns in table.

What is your requirement ?


KH

Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2006-10-04 : 06:10:46
resultsets are square - you can't include columns for some rows only.
If you use select * you will get all columns including null values.
You can list the columns to exclude those you don't want but that will be for all rows.

You can format the resultset into a single column with whatever format you want.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2006-10-04 : 06:52:02
Why not have your front end just not display the columns that are NULL ?

Kristen
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-10-04 : 11:06:34
quote:
Originally posted by Kristen

Why not have your front end just not display the columns that are NULL ?

Kristen


Thats what I wanted to ask the questioner

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2006-10-04 : 12:48:29
quote:
Originally posted by born2acheive

phone sex


Never have been a big fan

SELECT COALESCE(Salary,0)

Oh, and never use SELECT *, unless you should

http://weblogs.sqlteam.com/brettk/archive/2004/04/22/1272.aspx



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page
   

- Advertisement -