XML and Nulls

  • Thread starter Thread starter Matt Tapia
  • Start date Start date
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?
 
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
 
Back
Top