SQL 中对XML数据的修改
2010-07-16 16:56
411 查看
今天云次那个数据出错,一看,靠,原来的脚本Bat改称cmd了。只能修改数据了。
原来的数据:
修改命令:
该后的数据:
补充点详细资料:
modify方法
该方法可以对XML数据进行更新。通过XQuery中添加的insert、delete和update关键字提供了对XMLDML的支持,使用insert、delete和update关键字可以分别插入、删除和更新一个或多个节点。例如,在查询窗口中输入以下代码:
在该段代码的第1行使用UPDATE语句修改books表中xmlCol类型的字段,在第2~7行使用insert
[/code]
原来的数据:
<VStormCliCreator> <MachineName>B1-Site</MachineName> <NIC>TrunkNetworkSwitch</NIC> <Host>MSD-1531346.fareast.corp.microsoft.com</Host> <Memory>4096</Memory> <Password>User@123</Password> <VLanID>979</VLanID> <PostScripts> <PostScript>\\172.23.93.230\scratch$\v-XXX\Run.bat</PostScript> </PostScripts> <ImageName>97-SP2</ImageName> <OSID>97</OSID> </VStormCliCreator>
修改命令:
updatedbo.MachineConfigssetCreatorConfig.modify('replacevalueof
(/VStormCliCreator/PostScripts/PostScript/text())[1]with("\\172.23.93.230\scratch$\v-XXX\Run.cmd")')
whereID='49E6303D-577D-43C8-BB57-0533FC19BBEC' select*fromdbo.MachineConfigswhereID='49E6303D-577D-43C8-BB57-0533FC19BBEC'
该后的数据:
<VStormCliCreator> <MachineName>B1-Site</MachineName> <NIC>TrunkNetworkSwitch</NIC> <Host>MSD-1531346.fareast.corp.microsoft.com</Host> <Memory>4096</Memory> <Password>User@123</Password> <VLanID>979</VLanID> <PostScripts> <PostScript>\\172.23.93.230\scratch$\v-XXX\Run.cmd</PostScript> </PostScripts> <ImageName>97-SP2</ImageName> <OSID>97</OSID> </VStormCliCreator>
着重感谢郭勇成的《如何对SQLServer中的XML数据进行insertUpdatedelete》http://blog.csdn.net/tjvictor/archive/2009/07/21/4368496.aspx
补充点详细资料:
modify方法
该方法可以对XML数据进行更新。通过XQuery中添加的insert、delete和update关键字提供了对XMLDML的支持,使用insert、delete和update关键字可以分别插入、删除和更新一个或多个节点。例如,在查询窗口中输入以下代码:
UPDATEbooksSETxmlCol.modify('insert<sectionnum="1"><content>Background</content></section>after(/book/title)[1]')whereid=1
在该段代码的第1行使用UPDATE语句修改books表中xmlCol类型的字段,在第2~7行使用insert
代码[code]<booktype="computer"publicationdate="2008"ISBN="0-7356-1588-2">
<title>c#</title>
<sectionnum="1">
<content>Background</content>
</section>
<author>
<first-name>sheng</first-name>
<last-name>bin</last-name>
</author>
<author>
<first-name>gengxin</first-name>
<last-name>sun</last-name>
</author>
<price>35.99</price>
</book>
[/code]
相关文章推荐
- SQL XML DML 数据修改
- SQL 使用XML数据修改语言
- SQL 使用XML数据修改语言
- SQL存储过程-新增和修改,参数Xml数据类型
- 数据库操作_连接SQL Server数据库示例;连接ACCESS数据库;连接到 Oracle 数据库示例;SqlCommand 执行SQL命令示例;SqlDataReader 读取数据示例;使用DataAdapter填充数据到DataSet;使用DataTable存储数据库表;将数据库数据填充到 XML 文件;10 使用带输入参数的存储过程;11 使用带输入、输出参数的存储过程示;12 获得数据库中表的数目和名称;13 保存图片到SQL Server数据库示例;14 获得插入记录标识号;Exce
- SQL语句汇总——数据修改、数据查询
- 【转】sql多行数据拼接OUTER APPLY,CROSS APPLY,FOR XML AUTO
- SQL规范化的数据修改语句
- Querying Microsoft SQL Server 2012 读书笔记:查询和管理XML数据 2 -使用XQuery 查询XML数据
- 批量生成修改数据库表字段类型SQL脚本
- SQL语句,数据更新,数据插入删除修改和对视图的更新操作
- 全国省份、城市、地区全数据(SQL版与XML版)包括各城市邮编
- DataSet SqlCommandBuilder添加修改删除数据
- 修改Android中strings.xml文件, 动态改变数据
- C#中DataGrid加载XML数据--在另外一页面修改数据
- 修改Android中strings.xml文件, 动态改变数据
- vbscript 和qc api 通过sql 语句查询数据 组装成 xml 文件
- MySQL 修改数据表sql语句
- C# + SqlServer 2008 使用XML大批量数据入库
- DataList绑定xml数据,并实现删除和修改