DECLARE @myDoc XML
SET @myDoc = '<Root>       
   <ProductDescription ProductID="1" ProductName="Road Bike">           
    <Features> </Features>           
</ProductDescription>     
</Root>'
DECLARE @NewFeatures XML
SET @NewFeatures = N'<ride>people could ride bike</ride>
                    <sport>ride bike is a sport</sport>'SET    @myDoc.modify('
insert sql:variable("@NewFeatures") 
into (/Root/ProductDescription/Features)[1]')
SELECT     @myDoc;
这一段怎么在SQL2005中运行出错啊?
消息 6739,级别 16,状态 1,第 13 行
XQuery: 在 XQuery 中不支持 SQL 类型 'xml'。

解决方案 »

  1.   

    XML还不怎么懂  DECLARE @myDoc XML
    SET @myDoc = '<Root>       
       <ProductDescription ProductID="1" ProductName="Road Bike">           
        <Features> </Features>           
    </ProductDescription>     
    </Root>'
    DECLARE @NewFeatures XML
    SET @NewFeatures = N'<ride>people could ride bike</ride>
                        <sport>ride bike is a sport</sport>'SET    @myDoc.modify('
    insert sql:variable("@NewFeatures") 
    into (/Root/ProductDescription/Features)[1]')
    SELECT     @myDoc;
    /*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    <Root><ProductDescription ProductID="1" ProductName="Road Bike"><Features><ride>people could ride bike</ride><sport>ride bike is a sport</sport></Features></ProductDescription></Root>(1 行受影响)*/2008才支持这种写法
      

  2.   

    08上没有问题,05也支持xml类型字段操作。
      

  3.   


    --SQL 2005 
    /*错误消息消息 6739,级别 16,状态 1,第 13 行
    XQuery: 在 XQuery 中不支持 SQL 类型 'xml'。*/