zoukankan      html  css  js  c++  java
  • XMLvariable AND as last

     
    --replace   with sql:variable("@SEX")  
     
    DECLARE @x1 XML 
     
    SELECT @x1 = '<People NAME="dongshengSEX="女"/>
     
    DECLARE @SEX1 NVARCHAR(10) 
     
    SELECT @SEX1 = '男' 
     
    SET @x1.modify('replace value of (/People/@SEX)[1]     with sql:variable("@SEX1")') 
     
     
      
     
    /*<People NAME="dongshengSEX="男" />*/ 
     
     
     
    ----insert attribute 
     
    DECLARE @x2 XML 
     
    SELECT @x2= '<People NAME="dongsheng" />
     
    DECLARE @SEX2 VARCHAR(15) 
     
    SELECT @SEX2 = '男' 
     
    SET @x2.modify('    insert attribute SEX {sql:variable("@SEX2")} as last into   (/People)[1]') 
     
     
      
    /*<People NAME="dongshengSEX="男" />*/ 
     
    --insert element 
    DECLARE @x3 XML 
     
    SELECT @x3 ='<People NAME="dongsheng">  <SEX2>女</SEX2> </People>
     
    DECLARE @SEX3 VARCHAR(15) 
     
    SELECT @SEX3 = '男' 
     
    SET @x3.modify('    insert element SEX {sql:variable("@SEX3")} as last into    
     
    (/People)[1]') 
     
    SELECT @x3 
     
    /* 
     
    <People NAME="dongsheng"> 
      <SEX2>女</SEX2> 
      <SEX>男</SEX> 
    </People> 
     
    */ 
     
     
     
     
     
  • 相关阅读:
    Leetcode: Reverse Integer
    Leetcode: Two Sum
    Leetcode: Path Sum
    make distclean
    makefile 中 foreach
    nor flash 和 nand flash
    端口(port)的安全模式(security mode)
    单片机入门(二)
    单片机入门(一)
    kworker
  • 原文地址:https://www.cnblogs.com/qanholas/p/1865357.html
Copyright © 2011-2022 走看看