在我的数据库 ( GoogleSEOData
) 中,我有一个表 (GoogleMarkupList),表中有以下示例数据:
PUBLICATION_ID | PAGEID | URL
-------------------------------------------------------------
233 | 654345 | /english/index.aspx
345 | 654345 | /de/english/index.aspx
432 | 654345 | /ru/russian/index.aspx
533 | 654345 | /ae/arabic/index.aspx
233 | 452323 | /english/offers.aspx
345 | 452323 | /de/english/offers.aspx
432 | 452323 | /ru/russian/offers.aspx
533 | 452323 | /ae/arabic/offers.aspx
233 | 834343 | /english/destinations.aspx
345 | 834343 | /de/english/destinations.aspx
432 | 834343 | /ru/russian/destinations.aspx
533 | 834343 | /ae/arabic/destinations.aspx
现在我想编写 SQL 过程,它将服务器的文件路径作为输入(D://GoogleMarkup),并在服务器上创建以下类型的 XML 文件(对于上述示例数据)。
654345 类型数据的 XML 文件的名称将是654345.XML
<ps>
<p n="233" u="/english/index.aspx" />
<p n="345" u="/de/english/index.aspx" />
<p n="432" u="/ru/russian/index.aspx" />
<p n="533" u="/ae/arabic/index.aspx" />
</ps>
452323 类型数据的 XML 文件的名称将是452323.XML
<ps>
<p n="233" u="/english/offers.aspx" />
<p n="345" u="/de/english/offers.aspx" />
<p n="432" u="/ru/russian/offers.aspx" />
<p n="533" u="/ae/arabic/offers.aspx" />
</ps>
834343 类型数据的 XML 文件的名称将是834343.XML
<ps>
<p n="233" u="/english/destinations.aspx" />
<p n="345" u="/de/english/destinations.aspx" />
<p n="432" u="/ru/russian/destinations.aspx" />
<p n="533" u="/ae/arabic/destinations.aspx" />
</ps>
我知道有实用性
SQLCMD -S Server -d Database -E -v pageid=%pid%
-Q "Select publication_id as [n], url from table as [p] where pageid=$(pageid) for xml auto, root('ps')"
-o D://GoogleMarkup/%pid%.xml
但是如何一次创建所有的XML,以便它会一个一个地读取pageid并传递SQLCMD
给创建XML,我是否需要为此编写游标,请提供一些好的代码示例。
请推荐!!