哪里不对啊?
我怎么给
select top 10
ROW_NUMBER() over (order by countnum desc) as topid,
photoid ,viewcount
from ATable
for xml RAW('Photos'),root('TopList') 里面出来的xml
<TopList>
<Photos topid="1" photoid="1" viewcount="3500" />
<Photos topid="2" photoid="2" viewcount="1000" />
</TopList>
设置声明啊
我怎么给
select top 10
ROW_NUMBER() over (order by countnum desc) as topid,
photoid ,viewcount
from ATable
for xml RAW('Photos'),root('TopList') 里面出来的xml
<TopList>
<Photos topid="1" photoid="1" viewcount="3500" />
<Photos topid="2" photoid="2" viewcount="1000" />
</TopList>
设置声明啊
我觉得 declare @temp xml(HistoryTopSchema)
这里已经定义XML架构信息HistoryTopSchema
但是@temp在赋予的值里面没有
<TopList>
<Photos topid="1" photoid="1" viewcount="3500" />
<Photos topid="2" photoid="2" viewcount="1000" />
</TopList>
没有架构信息,sql 报错找不到元素 'TopList' 的声明。位置: /*:TopList[1] 可以理解。问题是咋给toplist加上声明就不懂了,第一次用类型化XML很晕啊。看了示例都是可以直接插的不会报没声明的错误,真郁闷
我测试忘记加SCHEMA了
N'<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:sqltypes="http://schemas.microsoft.com/sqlserver/2004/sqltypes" elementFormDefault="qualified" >
<xsd:import namespace="http://schemas.microsoft.com/sqlserver/2004/sqltypes" schemaLocation="http://schemas.microsoft.com/sqlserver/2004/sqltypes/sqltypes.xsd" />
<xsd:element name="TopList">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="unbounded" name="Photos">
<xsd:complexType>
<xsd:attribute name="topid" type="xsd:unsignedByte" use="required" />
<xsd:attribute name="photoid" type="xsd:unsignedInt" use="required" />
<xsd:attribute name="viewcount" type="xsd:unsignedInt" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>' ;
貌似你的架构比我少个 targetNamespace="http://fire2
为啥呢?那个是干什么用的?