sql xml xquery (4)
2013-04-12 13:26
302 查看
1, DECLARE @myDoc xml SET @myDoc = '<?Instructions for=TheWC.exe ?> <Root> <!-- instructions for the 1st work center --> <Location LocationID="10" LaborHours="1.1" MachineHours=".2" >Some text 1 <step>Manufacturing step 1 at this work center</step> <step>Manufacturing step 2 at this work center</step> </Location> </Root>' SELECT @myDoc -- delete an attribute SET @myDoc.modify(' delete /Root/Location/@MachineHours ') SELECT @myDoc -- delete an element SET @myDoc.modify(' delete /Root/Location/step[2] ') SELECT @myDoc -- delete text node (in <Location> SET @myDoc.modify(' delete /Root/Location/text() ') SELECT @myDoc -- delete all processing instructions SET @myDoc.modify(' delete //processing-instruction() ') SELECT @myDoc 2, use msdb CREATE TABLE T (i int, x xml) go INSERT INTO T VALUES(1,'<Root> <ProductDescription ProductID="1" ProductName="Road Bike"> <Features> <Warranty>1 year parts and labor</Warranty> <Maintenance>3 year parts and labor extended maintenance is available</Maintenance> </Features> </ProductDescription> </Root>') go -- verify the contents before delete SELECT x.query(' //ProductDescription/Features') FROM T -- delete the second feature UPDATE T SET x.modify('delete /Root/ProductDescription/Features/*[2]') -- verify the deletion SELECT x.query(' //ProductDescription/Features') FROM T DROP TABLE T
相关文章推荐
- XQuery与SQL/XML
- sql xml xquery (1)
- T-SQL XQuery (XML路径查询) (转)http://blog.csdn.net/Beirut/article/details/8150116
- Querying Microsoft SQL Server 2012 读书笔记:查询和管理XML数据 2 -使用XQuery 查询XML数据
- (转)sql:variable() binding and modify method of xquery: insert XML DML
- sql xml xquery (2)
- xquery:xml的sql
- Querying Microsoft SQL Server 2012 读书笔记:查询和管理XML数据 2 -使用XQuery 查询XML数据
- SQL Server XML基础学习之<5>--XQuery(query)
- sql xml xquery (3)
- SQL中的XML,XPath,XQuery查询方法
- SQL中XQuery/XML的应用
- SQL中的XML,XPath,XQuery查询方法
- SQL中的XML,XPath,XQuery查询方法
- Oracle XQuery 过滤XML查询SQL
- Mybatis的selectKey——xml映射和注解映射sql
- 在Mybatis中关于xml中sql语句的一些注意事项,再补充
- SQL2005 XML 的例子
- Oracle由SQL查询生成XML
- Sql 对XML的支持