469,642 Members | 1,279 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,642 developers. It's quick & easy.

Simple select question!

Hi,

I feel so stupid to ask this question, but here it goes

When I select a column from a table, if the column has a null value I
want the select to return me a blank. I have done this before but I
forgot, some one help?

select name, age from people

in the above query the name can be null. I do not want to do

select @name=name....

Thanks.

Jul 23 '05 #1
4 1044
COALESCE(name,'')

--
David Portas
SQL Server MVP
--

Jul 23 '05 #2
"DBC User" <ks*****@yahoo.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
Hi,

I feel so stupid to ask this question, but here it goes

When I select a column from a table, if the column has a null value I
want the select to return me a blank. I have done this before but I
forgot, some one help?

select name, age from people

in the above query the name can be null. I do not want to do

select @name=name....

Thanks.


Use the COALESCE function, e.g.,

SELECT COALESCE(name, ' '), age
FROM People

--
JAG
Jul 23 '05 #3
DBC User,

Is this what you mean?

SELECT CASE WHEN [Name] IS NULL THEN '' ELSE [Name] END AS [Name], Age FROM
People

btw, don't use 'Name' as a column name, it is a reserved word in SQL.

-Andy

"DBC User" <ks*****@yahoo.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
Hi,

I feel so stupid to ask this question, but here it goes

When I select a column from a table, if the column has a null value I
want the select to return me a blank. I have done this before but I
forgot, some one help?

select name, age from people

in the above query the name can be null. I do not want to do

select @name=name....

Thanks.

Jul 23 '05 #4
Thanks all for the answer. I was looking for COALESCE

Jul 23 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Scott | last post: by
13 posts views Thread by LRW | last post: by
5 posts views Thread by Stephanie_Stowe | last post: by
5 posts views Thread by Tim::.. | last post: by
7 posts views Thread by Scott Frankel | last post: by
3 posts views Thread by Chrism2671 | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.