Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2005 > BOOK: Professional SQL Server 2005 XML ISBN: 0-7645-9792-2
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional SQL Server 2005 XML ISBN: 0-7645-9792-2
This is the forum to discuss the Wrox book Professional SQL Server 2005 XML by Scott Klein; ISBN: 9780764597923
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional SQL Server 2005 XML ISBN: 0-7645-9792-2 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old June 17th, 2009, 10:49 AM
Registered User
 
Join Date: Jun 2009
Posts: 8
Thanks: 1
Thanked 0 Times in 0 Posts
Exclamation Problem loading datetime values from XML

Hello,

I extracted xml using "for xml" clause from Production.ProductCategory table in AdventureWorks.

The ModifiedDate is extracted as "1998-06-01T00:00:00".

When I try to load this XML (using BulkLoad) into another sql server instance, I get "Invalid character value for cast specification" error.

My xsd schema looks like this:
Code:
<xs:element name="ModifiedDate" sql:field="ModifiedDate" type="xs:dateTime"/>
What works as the date value:
6/1/8

What else does not work as date value:
1998-06-01T00:00:00Z
1998-06-01T00:00:00.000Z

I would appreciate any pointers.

Regards.

Ash
Reply With Quote
  #2 (permalink)  
Old June 22nd, 2009, 08:49 PM
SQLScott's Avatar
Wrox Author
 
Join Date: Dec 2004
Location: Wellington, FL , USA.
Posts: 338
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Hi Ash,

I've had this problem as well. The date going in needs to be in datetime format and 1998-06-01T00:00:00 does not meet that criteria. For example, the following is datetime format:

2009-06-22 20:47:20.427

Try the following: change the value to 1998-06-01 00:00:00 and see if it goes in that way.

Scott
__________________
========================
Scott Klein
Author of:
Professional SQL Server 2005 XML
Professional WCF Programming: .NET Development with the Windows Communication Foundation
Professional LINQ
========================
Reply With Quote
  #3 (permalink)  
Old June 23rd, 2009, 08:26 AM
Registered User
 
Join Date: Jun 2009
Posts: 8
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Hi Scott,

Thanks for the reply. I am sorry, I should posted the solution before. You are right, The dates need to exported in any date format which SQL Server natively recognizes. I tried simple mm/dd/yyyy (time was not that important) and it worked.

Regards.

Ash
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Searching between 2 DateTime Values using SELECT stmt in Vb.Net remya1000 SQL Language 3 February 24th, 2009 02:49 PM
Error in loading XML. nikhil_vaghela XML 3 May 15th, 2008 08:19 AM
Loading Xml Files in session causes problem umair.hasan ASP.NET 1.0 and 1.1 Professional 1 February 26th, 2008 03:02 AM
Problem reading datetime values eresina ADO.NET 0 February 5th, 2005 11:51 AM
Xml Dcument not loading bearpaws XML 3 November 14th, 2003 12:29 PM



All times are GMT -4. The time now is 09:53 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.