XML and Nulls

M

Matt Tapia

I have a table with 3 columns (CustomerID, CustomerFirstName,
CustomerLastName). I select the one row from that table and put it into a
dataset then write an XML file. However, the CustomerFirstName value is NULL
and it did not write a <CustomerFirstName> tag to the XML file.

I then take the XML file to another application that reads it into a
dataset. I remove the one row from the dataset then create a new datarow
that specifices what the CustomerFirstName. However because the
<CustomerFirstName> tag to the XML file was not in the XML file, it will not
allow be to add it the XML file. What can I do?
 
C

ciroque

Matt,

In your SQL statement use

COALESCE( CustomerFirstName, '' ) AS CustomerFirstName

to retrieve that column (or any columns that could potentially be
NULL).

This will return an empty string where NULL's exist and allow the
element to be written to the XML file.

Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top