xml-dml

How to exclude more than one node, so one of those exclude will rearrange its attributes using XML DML?

耗尽温柔 提交于 2019-12-25 08:32:57
问题 this is a reference from this posted question, as I am looking to rearrange the value of attribute <pos> inside nodes <est_mat> , so the first node of <est_mat> will have <pos>10</pos> , then the second <est_mat> node will have <pos>20</pos> and so on. I have this query from the help of one of the users from the posted reference mentioned. So, supposing the following xml structure: DECLARE @xml XML= N'<flint> <app> <comp>59</comp> <signal>ORDERBOOK</signal> <sigref>000000172</sigref> <date

Inserting an attribute in multiple XML Nodes using XML.modify() in SQL 2005

别说谁变了你拦得住时间么 提交于 2019-12-22 06:06:14
问题 I have an @XML document created from a single select statement. <root> <node> <node1> <targetNode> </targetNode> </node1> <node1> <targetNode> </targetNode> </node1> <node1> <targetNode> </targetNode> </node1> </node> <node> ...... </node> </root> I want to insert the xsi:nil as an attribute of 'targetNode' for this document. @XML.modify( 'insert attribute xsi:nil {"true"} into (root/node/node1/targetNode) [1]') The above will insert the attribute into the first occurance of the targetNode in

How to update the existing node value of XML by multiplying it with n times in SQL Server

末鹿安然 提交于 2019-12-11 09:00:35
问题 Here is the XML I have in my Table Field <CtcConfiguration xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Ctc>3</Ctc> <SalaryComponent> <SalaryComponentConfiguration> <Name>Basic</Name> <DisplayOrder>0</DisplayOrder> <Value>5634655</Value> </SalaryComponentConfiguration> <SalaryComponentConfiguration> <Name>HR</Name> <DisplayOrder>0</DisplayOrder> <Value>1234</Value> </SalaryComponentConfiguration> <SalaryComponentConfiguration> <Name

SQL Server 2008: Rename an element using XML DML?

故事扮演 提交于 2019-12-10 19:18:23
问题 Is it possible to use an XML DML statement to rename an element in an untyped XML column? I am in the process of updating an XML Schema Collection on an XML column and need to patch the existing XML instances by renaming one element before I can apply the latest schema. As far as I can tell from the docs you can only insert / delete nodes or replace their value. 回答1: As the saying goes, "Where there's a will there's a way" Here's two methods: the first is to simply replace the previous xml

How to change node value using node's current value in SQL with XQuery (SQL Server)

允我心安 提交于 2019-12-08 06:45:59
问题 How can I change: <data> <row> <a>A</a> <a>B</a> <a>C</a> </row> </data> to: <data> <row> <a>Data A</a> <a>Data B</a> <a>Data C</a> </row> </data> in SQL? I've seen lots of examples on how to completely replace a value with a static value, but no examples of replacing the value dynamically. 回答1: I do not know if it is possible to use the xml in the replace value of statement. But you can do this. declare @xml xml = ' <data> <row> <a>A</a> <a>B</a> <a>C</a> </row> </data>' declare @Val1

How to change node value using node's current value in SQL with XQuery (SQL Server)

落花浮王杯 提交于 2019-12-08 04:31:27
How can I change: <data> <row> <a>A</a> <a>B</a> <a>C</a> </row> </data> to: <data> <row> <a>Data A</a> <a>Data B</a> <a>Data C</a> </row> </data> in SQL? I've seen lots of examples on how to completely replace a value with a static value, but no examples of replacing the value dynamically. I do not know if it is possible to use the xml in the replace value of statement. But you can do this. declare @xml xml = ' <data> <row> <a>A</a> <a>B</a> <a>C</a> </row> </data>' declare @Val1 varchar(10) declare @Val2 varchar(10) declare @Val3 varchar(10) select @Val1 = 'Data '+r.value('a[1]', 'varchar(1)

Inserting an attribute in multiple XML Nodes using XML.modify() in SQL 2005

不羁的心 提交于 2019-12-05 10:29:44
I have an @XML document created from a single select statement. <root> <node> <node1> <targetNode> </targetNode> </node1> <node1> <targetNode> </targetNode> </node1> <node1> <targetNode> </targetNode> </node1> </node> <node> ...... </node> </root> I want to insert the xsi:nil as an attribute of 'targetNode' for this document. @XML.modify( 'insert attribute xsi:nil {"true"} into (root/node/node1/targetNode) [1]') The above will insert the attribute into the first occurance of the targetNode in the @XML document. The insert statement however will only work on a single node. Is there any way I

XML DML for 2008 R2..How to modify nested Elements

余生长醉 提交于 2019-11-29 17:10:20
<Component> <Caption>2 7/8" x 1",Drill Collar,2 3/8 PAC</Caption> <Description>2 7/8" x 1",Drill Collar,2 3/8 PAC</Description> <Count>1</Count> <Sections> <Section> <Material>Steel AISI 4145</Material> <Connection>2 3/8 PAC</Connection> <Weight>28.7197</Weight> <Length>0.508</Length> </Section> <Section> <Material>Steel AISI 4145</Material> <Connection>NC50</Connection> <Weight>28.7197</Weight> <Length>0.508</Length> </Section> <Section> <Material>Steel AISI 4145</Material> <Connection>NC36</Connection> <Weight>28.7197</Weight> <Length>0.508</Length> </Section> </Sections> </Component> I have

How to delete an attribute from an XML variable in sql server 2008?

巧了我就是萌 提交于 2019-11-29 14:02:38
I have a table called XML (in SQL Server 2008) and it has a field called XmlDocument of type XML . I am trying to to delete an attribute from an XML variable. Here is how my xml looks like <clue_personal_auto xmlns="http://cp.com/rules/client"> <admin> <receipt_date>03/16/2011</receipt_date> <date_request_ordered>03/16/2011</date_request_ordered> <report_usage>Personal</report_usage> </admin> </clue_personal_auto> My query UPDATE XML SET XmlDocument.modify('delete (/clue_personal_auto/@xmlns)[1]') WHERE xmlid = 357 When I run this query in query analyzer I see the message "1 row(s) affected"

XML DML for 2008 R2..How to modify nested Elements

て烟熏妆下的殇ゞ 提交于 2019-11-28 10:40:05
问题 <Component> <Caption>2 7/8" x 1",Drill Collar,2 3/8 PAC</Caption> <Description>2 7/8" x 1",Drill Collar,2 3/8 PAC</Description> <Count>1</Count> <Sections> <Section> <Material>Steel AISI 4145</Material> <Connection>2 3/8 PAC</Connection> <Weight>28.7197</Weight> <Length>0.508</Length> </Section> <Section> <Material>Steel AISI 4145</Material> <Connection>NC50</Connection> <Weight>28.7197</Weight> <Length>0.508</Length> </Section> <Section> <Material>Steel AISI 4145</Material> <Connection>NC36<