抄来的别人总结的一段,为什么出错呢?

我不要昵称 2012-11-06 10:03:12
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'。
...全文
168 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
ChangeMyself2012 2012-11-06
  • 打赏
  • 举报
回复

--SQL 2005 
/*错误消息

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

*/
我不要昵称 2012-11-06
  • 打赏
  • 举报
回复
没人在SQL2005上试试????
我不要昵称 2012-11-06
  • 打赏
  • 举报
回复
2005上为什么执行报错啊?
快溜 2012-11-06
  • 打赏
  • 举报
回复
08上没有问题,05也支持xml类型字段操作。
我不要昵称 2012-11-06
  • 打赏
  • 举报
回复
SQL2005不支持这种写法??
  • 打赏
  • 举报
回复
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才支持这种写法

34,589

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧