1
我正在構建一個自己使用的工具,其中一些功能允許我將表從SQL數據庫導入和導出爲XML格式。我的公司有一個工具可以完成這項工作,但只允許導入/導出,而不需要添加其他功能。我有我們的舊工具輸出的一些XML文件的副本,我正在尋找複製它輸出的格式。下面是這種格式。確定用於XML格式化的SQL查詢
<?xml version="1.0" standalone="yes"?>
<NewDataSet>
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="ini_files">
<xs:complexType>
<xs:sequence>
<xs:element name="instance" type="xs:int" minOccurs="0" />
<xs:element name="file" type="xs:string" minOccurs="0" />
<xs:element name="section" type="xs:string" minOccurs="0" />
<xs:element name="key" type="xs:string" minOccurs="0" />
<xs:element name="value" type="xs:string" minOccurs="0" />
<xs:element name="last_updated" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<ini_files>
<instance>0</instance>
<file>versions.ini</file>
<section>Actual Versions</section>
<key>28.000</key>
<value>28.000</value>
<last_updated>2015-08-25T17:44:10Z</last_updated>
</ini_files>
<ini_files>
<instance>0</instance>
<file>dsconnection.ini</file>
<section>User</section>
<key>CD Key</key>
<value>86BC011090861C115020</value>
<last_updated>2016-02-17T03:32:20Z</last_updated>
</ini_files>
<ini_files>
<instance>0</instance>
<file>dsconnection.ini</file>
<section>Install</section>
<key>Serial Number</key>
<value>492679715G806LS|1570621586</value>
<last_updated>2016-02-19T00:23:40Z</last_updated>
</ini_files>
<ini_files>
<instance>0</instance>
<file>dsconnection.ini</file>
<section>User</section>
<key>Connect</key>
<value>dsconnection</value>
<last_updated>2016-02-17T03:32:20Z</last_updated>
</ini_files>
<ini_files>
<instance>0</instance>
<file>dsconnection.ini</file>
<section>dsconnection</section>
<key>IP Address</key>
<value>127.0.0.1,192.168.0.1,192.168.1.1</value>
<last_updated>2016-02-26T00:26:25Z</last_updated>
</ini_files>
<ini_files>
<instance>0</instance>
<file>dsconnection.ini</file>
<section>dsconnection</section>
<key>Port</key>
<value>8080</value>
<last_updated>2015-08-25T17:44:11Z</last_updated>
</ini_files>
<ini_files>
<instance>0</instance>
<file>dsconnection.ini</file>
<section>dsconnection</section>
<key>Company Type</key>
<value>1</value>
<last_updated>2016-02-17T03:32:08Z</last_updated>
</ini_files>
<ini_files>
<instance>0</instance>
<file>dsconnection.ini</file>
<section>dsconnection</section>
<key>Environment</key>
<value>3Ljf10vSut+g5Pcsu4qwVnjwCN4SEoL8</value>
<last_updated>2016-02-26T00:26:26Z</last_updated>
</ini_files>
<ini_files>
<instance>0</instance>
<file>dsconnection.ini</file>
<section>User</section>
<key>Address</key>
<value>TESTING--ADDRES--VALUE</value>
<last_updated>2016-02-19T00:23:57Z</last_updated>
</ini_files>
<ini_files>
<instance>0</instance>
<file>dsconnection.ini</file>
<section>User</section>
<key>Temporary Address</key>
<value>78577739280119836672551</value>
<last_updated>2016-02-17T03:32:09Z</last_updated>
</ini_files>
<ini_files>
<instance>0</instance>
<file>versions.ini</file>
<section>Profile Versions</section>
<key>Last Modified</key>
<value>2016-02-22T14:22:49</value>
<last_updated>2016-02-22T21:22:49Z</last_updated>
</ini_files>
<ini_files>
<instance>0</instance>
<file>dsconnection.ini</file>
<section>dsconnection</section>
<key>Last Connected</key>
<value>2016-02-25T17:26:36</value>
<last_updated>2016-02-26T00:26:36Z</last_updated>
</ini_files>
<ini_files>
<instance>0</instance>
<file>desktop.ini</file>
<section>Online</section>
<key>Last Sent Info</key>
<value>2016-02-25T01:43:09.3739698Z</value>
<last_updated>2016-02-25T01:43:09Z</last_updated>
</ini_files>
</NewDataSet>
我與SQL很缺乏經驗,但在這裏,我找到了,讓我從我們的表導出到XML查詢,但格式是完全關閉。
osql -S (local)\instancename -U sa -P [email protected] db_name -oC:\testing.xml -Q"SELECT * from ini_files for XML AUTO, BINARY BASE64"
如果我不BINARY BASE64
導出拋出這個錯誤。
FOR XML AUTO requires primary keys to create references for 'data'.
Select primary keys, or use BINARY BASE64 to obtain binary data in
encoded form if no primary keys exist.
我嘗試使用XML RAW
以及它會引發此錯誤。
FOR XML EXPLICIT and RAW modes currently do not support addressing
binary data as URLs in column 'data'. Remove the column, or use the
BINARY BASE64 mode, or create the URL directly using the
'dbobject/TABLE[@PK1="V1"]/@COLUMN' syntax.
我做了一些搜索,但無法找到任何具體的複製輸出。
任何人都可以確定使用什麼命令導出上面列出的XML嗎?任何幫助將不勝感激。
從SQL Server ** 2005 **起,您應該停止使用'isql'和'osql'並使用'sqlcmd'來代替 –