I am running into an issue when adding data from multiple columns into
one alias:
P.ADDR1 + ' - ' + P.CITY + ',' + ' ' + P.STATE AS LOCATION
If one of the 3 values is blank, the value LOCATION becomes NULL. How
can I inlcude any of the 3 values without LOCATION becoming NULL?
Example, if ADDR1 and CITY have values but STATE is blank, I get a
NULL statement for LOCATION. I still want it to show ADDR1 and CITY
even if STATE is blank.
Thanks 4 1798
ISNULL(P.CITY,' ')
Techhead wrote:
I am running into an issue when adding data from multiple columns into
one alias:
P.ADDR1 + ' - ' + P.CITY + ',' + ' ' + P.STATE AS LOCATION
If one of the 3 values is blank, the value LOCATION becomes NULL. How
can I inlcude any of the 3 values without LOCATION becoming NULL?
Example, if ADDR1 and CITY have values but STATE is blank, I get a
NULL statement for LOCATION. I still want it to show ADDR1 and CITY
even if STATE is blank.
Thanks
You can use COALESCE, something like this will do it:
COALESCE(P.ADDR 1, '') + ' - ' + COALESCE(P.CITY , '') + ', ' +
COALESCE(P.STAT E, '') AS LOCATION
Also, you can play with formatting variations based on what you want to get
when one of the columns is NULL, like this:
COALESCE(P.ADDR 1, '') + COALESCE(' - ' + P.CITY, '') + COALESCE(', ' +
P.STATE, '') AS LOCATION
HTH,
Plamen Ratchev http://www.SQLStudio.com
On Jun 4, 3:29 pm, "Plamen Ratchev" <Pla...@SQLStud io.comwrote:
You can use COALESCE, something like this will do it:
COALESCE(P.ADDR 1, '') + ' - ' + COALESCE(P.CITY , '') + ', ' +
COALESCE(P.STAT E, '') AS LOCATION
Also, you can play with formatting variations based on what you want to get
when one of the columns is NULL, like this:
COALESCE(P.ADDR 1, '') + COALESCE(' - ' + P.CITY, '') + COALESCE(', ' +
P.STATE, '') AS LOCATION
HTH,
Plamen Ratchevhttp://www.SQLStudio.c om
Somebody at work told me to use this:
SELECT CASE WHEN P.STATE IS NULL THEN '' ELSE P.STATE END
It seems to work. Is this similar as to what is described above? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Steve Walker |
last post by:
Hi all.
I've been tasked with "speeding up" a mid-sized production system. It
is riddled with nulls... "IsNull" all over the procs, etc.
Is it worth it to get rid of the nulls and not allow them in the
columns anymore?
If so, how to go about removing the nulls with a script?
|
by: Cro |
last post by:
Dear Access Developers,
The 'Allow Additions' property of my form is causing unexpected
results.
I am developing a form that has its 'Default View' property set to
'Continuous Forms' and am displaying records that match an SQL
statement entered in the 'Record Source' property of the form.
The form behaves correctly and displays the...
|
by: Mike |
last post by:
The current databas structure that i'm working with allowed NULL's an now
I'm converting the app to .NET and it will not allow NULLs in the fields
when populated.
So my question is, how can i hande NULL's being pulled from the DB now?
When I try to access a page and if the field is NULL I get an error:
i do i fix this? I'm using VB.NET...
|
by: Gary Blakely |
last post by:
I'm giving this post another try - it can't be too difficult for
everyone....
In the program below, the web page has dataGrid1. the only thing that has
been done to it at design time is to check the "Create columns automatically
at runtime" checkbox - nothing else.
The code below does indeed create the visual grid as expected. ...
|
by: Edmund Dengler |
last post by:
Howdy all!
Just checking on whether this is the expected behaviour. I am transferring
data from multiple databases to single one, and I want to ensure that I
only have unique rows for some tables. Unfortunately, some of the rows
have nulls for various columns, and I want to compare them for exact
equality.
=> create table tmp (
bigint a,
| |
by: Martin Joergensen |
last post by:
Hi,
I have some files which has the following content:
0 0 0 0 0 0
0 1 1 1 1 0
0 1 1 1 1 0
0 1 1 1 1 0
0 1 1 1 1 0
0 0 0 0 0 0
|
by: Bob Stearns |
last post by:
I am creating an index on a column which is 40% NULLS. The process seems
to run forever, though a count of the number of values runs in
milliseconds. This leads to the subject question: is there a way to
ignore those rows with nulls in index creation?
|
by: markjerz |
last post by:
Hi,
I basically have two tables with the same structure. One is an archive
of the other (backup). I want to essentially insert the data in to the
other.
I use:
INSERT INTO table ( column, column .... )
SELECT * FROM table2
|
by: Chris |
last post by:
I have created a datatable from a csv file. One of the columns is an integer
which sometimes can be blank. When it is blank I add a dbnull.value to the
column when I add to the datatable. This doesn't throw an error but when I
do my bulk insert I get a 'data input' error. When I replace the nulls with
a value it works. What am I doing wrong....
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |