g***@yahoo.com
2013-05-04 04:40:05 UTC
I have an xml document stored in a table column that has inaccurate times in the date fields
I 'd like to update all LineStartTime and LineEndTime values in the document by 15 seconds so, for instance, 2012-02-01T00:07:00 becomes 2012-02-01T00:07:15 (long story as to why it needs to be this way; it's out of my hands). There can be 1 to many transactions and each transaction can have 1 or more line entries.
I have tried OPENXML, modify method, etc and I can't get it right. I am
at my wits end. Any help is appreciated. Thanks in advance!!
Sample is below
CREATE TABLE XMLTable (doc xml);
INSERT INTO XMLTable (doc)
VALUES
(
'<?xml version="1.0" encoding="UTF-8"?>
<Root>
<Transaction>
<SaleID>1</SaleID>
<Sale>
<SaleDateTime>2012-02-01T00:07:00</SaleDateTime>
<LineItem>
<Line>1</Line>
<LineStartTime>2012-02-01T00:07:00</LineStartTime>
<LineEndTime>2012-02-01T00:07:00</LineEndTime>
<Amount>13.50</Amount>
</LineItem>
</Sale>
</Transaction>
<Transaction>
<SaleID>2</SaleID>
<Sale>
<SaleDateTime>2012-02-01T00:11:00</SaleDateTime>
<LineItem>
<Line>1</Line>
<LineStartTime>2012-02-01T00:11:00</LineStartTime>
<LineEndTime>2012-02-01T00:11:00</LineEndTime>
<Amount>13.50</Amount>
</LineItem>
<LineItem>
<Line>2</Line>
<LineStartTime>2012-02-01T00:11:00</LineStartTime>
<LineEndTime>2012-02-01T00:11:00</LineEndTime>
<Amount>5.22</Amount>
</LineItem>
</Sale>
</Transaction>
</Root>')
SELECT * FROM XMLTable
I 'd like to update all LineStartTime and LineEndTime values in the document by 15 seconds so, for instance, 2012-02-01T00:07:00 becomes 2012-02-01T00:07:15 (long story as to why it needs to be this way; it's out of my hands). There can be 1 to many transactions and each transaction can have 1 or more line entries.
I have tried OPENXML, modify method, etc and I can't get it right. I am
at my wits end. Any help is appreciated. Thanks in advance!!
Sample is below
CREATE TABLE XMLTable (doc xml);
INSERT INTO XMLTable (doc)
VALUES
(
'<?xml version="1.0" encoding="UTF-8"?>
<Root>
<Transaction>
<SaleID>1</SaleID>
<Sale>
<SaleDateTime>2012-02-01T00:07:00</SaleDateTime>
<LineItem>
<Line>1</Line>
<LineStartTime>2012-02-01T00:07:00</LineStartTime>
<LineEndTime>2012-02-01T00:07:00</LineEndTime>
<Amount>13.50</Amount>
</LineItem>
</Sale>
</Transaction>
<Transaction>
<SaleID>2</SaleID>
<Sale>
<SaleDateTime>2012-02-01T00:11:00</SaleDateTime>
<LineItem>
<Line>1</Line>
<LineStartTime>2012-02-01T00:11:00</LineStartTime>
<LineEndTime>2012-02-01T00:11:00</LineEndTime>
<Amount>13.50</Amount>
</LineItem>
<LineItem>
<Line>2</Line>
<LineStartTime>2012-02-01T00:11:00</LineStartTime>
<LineEndTime>2012-02-01T00:11:00</LineEndTime>
<Amount>5.22</Amount>
</LineItem>
</Sale>
</Transaction>
</Root>')
SELECT * FROM XMLTable