Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1102919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:15:40+00:00 2026-05-17T01:15:40+00:00

I was wondering if someone could help I’ve successfully been able to import an

  • 0

I was wondering if someone could help

I’ve successfully been able to import an XML document to a table with an XML data type in SQL Server2008, how ever when I try and shred from that table to a staging table any DATE values without an entered date are inserted to the staging table as 1900-01-01.

Is there a cleaver way i’m missing to stop it doing this and simply insert NULL instead. I could use NULLIF on the staging table and replace 1900-01-01 with null but I’m reluctant to do this in case there are genuine 1900-01-01 values.

My code looks something like this

SELECT tab.col.value('LastDate[1]','DATE') LastARD'

FROM   import.XMLCompanyDetail

 CROSS APPLY
          xmldata.nodes('//VN/CompanyList/Row') AS tab(col)

Many thanks

Please see below the example XML i’m importing

<?xml version="1.0" encoding="ISO-8859-1" ?>
<VN>
<CompanyList>
<Row num="1"><CoNum>7878</CoNum><CoName>ExampleName</CoName><DInc>1978-12-30</DInc><DDis></DDis></Row>
</CompanyList>
</VN>

The date DDIS should be NULL but rather when it imports to my staging table it inserts 1901-01-01 instead.

updated code to show what I mean

create table staging_table
(DInc DATE NULL, LastARD DATE NULL);

with XMLCompanyDetail as 
(
SELECT CAST('<?xml version="1.0" encoding="ISO-8859-1" ?> 
<VN>
<CompanyList>
<Row num="1"><CoNum>7878</CoNum><CoName>ExampleName</CoName><DInc>1978-12-30</DInc><DDis></DDis></Row> 
</CompanyList>
</VN>
' AS XML) AS xmldata
)

INSERT INTO Staging_Table
SELECT tab.col.value('DInc[1]','DATE') DInc,
tab.col.value('DDis[1]','DATE') LastARD
FROM XMLCompanyDetail
CROSS APPLY
xmldata.nodes('//VN/CompanyList/Row') AS tab(col)

SELECT * FROM Staging_table
drop table staging_table
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T01:15:41+00:00Added an answer on May 17, 2026 at 1:15 am

    Edit

    Following Update to the question the following works but I’m not sure if there is a better way.

    SELECT tab.col.value('DInc[1][. != '''']','DATE') DInc,
    tab.col.value('DDis[1][. != '''']','DATE') LastARD
    FROM XMLCompanyDetail
    CROSS APPLY
    xmldata.nodes('//VN/CompanyList/Row') AS tab(col)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was wondering if someone would be able to help me write a CQL
Just wondering if someone could help me with the following issue. On my local
I was wondering if someone could help with an example criteria for nhibernate. I
I am wondering if someone could help me with some probably rather simple code,
I was wondering if someone could help me get pointers to solve this problem.
I was wondering if someone could help me using the JQuery validation plugin. I
I was wondering if someone could help me understand this problem. I prepared a
I was wondering if someone could help me to get this method converted to
I'm relatively new to hibernate and was wondering if someone could help me out.
I am no css expert so I am wondering whether someone could help. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.