473,387 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 1117
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Scott | last post by:
The following is the XML I have to work with. Below is the question <Table0> <CaseID>102114</CaseID> <CaseNumber>1</CaseNumber> <DateOpened>2005-06-14T07:26:00.0000000-05:00</DateOpened>...
6
by: calfliu | last post by:
hello: everybody! I have a simple question. How can I translate the selected value from art to recipient(hidden input button)? <form name="send" method="post" action="send.cgi"> <select...
13
by: LRW | last post by:
Having a problem getting a onSubmit function to work, to where it popsup a confirmation depending on which radiobutton is selected. Here's what I have: function checkdel() { if...
5
by: Stephanie_Stowe | last post by:
Hi. I am trying to get used to AS.NET. I have been doing ASP classic for years, and am now in a position to do ASP.NET. I am in the stumbling around until I get my bearings phase. I hope you will...
5
by: Tim::.. | last post by:
Can someone tell me how I convert this simple SQL statement so I can use it in ASP.NET??? I have an issue with the quotation marks and wondered if there is a simple rule for converting the sql...
13
by: Saber | last post by:
I did a lot of searches and read something about datagrids. But I couldn't find the answer of my simple question, how can I show only my desired columns of a table? for example I wrote this sql...
7
by: Scott Frankel | last post by:
Still too new to SQL to have run across this yet ... How does one return the latest row from a table, given multiple entries of varying data? i.e.: given a table that looks like this: color...
4
by: dba_222 | last post by:
Dear Experts, Ok, I hate to ask such a seemingly dumb question, but I've already spent far too much time on this. More that I would care to admit. In Sql server, how do I simply change a...
3
by: Chrism2671 | last post by:
I'm new to XSLT/XML and I have a very simple, quick question. i've been trying to convert simple xml files into CSV files and have made a simple XSLT template using the w3 tutorials, but it doesn't...
9
by: muddasirmunir | last post by:
i have a simple query and does not getting desire results which i want i am using vb6 and access i had a table with with 8 fields but just to simplyfy by question i am just supposing to four. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.