Hi,
I've inherited a mass of stored procedures that take as their only parameter a block of XML, the author then cracks it (using OPENXML) and then updates the a row.
I've come across a problem while updating a table that has datetime columns, the following is a snippet of data that currently fails:
declare @stuff nvarchar (max);
set @stuff =
'<Booking xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<UpdatedDateTime>2009-08-14T15:32:09.7240556+01:00</UpdatedDateTime>
</Booking>';
declare @iDoc int;
exec sp_xml_preparedocument @idoc OUTPUT, @stuff;
SELECT UpdatedDateTime
FROM
OPENXML(@idoc, '/*')
WITH
(
UpdatedDateTime datetime 'UpdatedDateTime'
)
Running that causes the following error:
Msg 241, Level 16, State 1, Line 12
Conversion failed when converting datetime from character string.
How do I go about converting the datetime from the XML fragment into a SQL based date time?
Thanks