問題描述
我有各種 xml 文檔需要存儲在數據庫列中.這些文檔包含對 DTD 的引用,并且 SQL Server 不會導入 xml,因為它存在安全風險.如何在數據庫上啟用 DTD 支持,以便我插入 xml 內容.
I have various xml documents that I need to store in a database column. The documents contain references to a DTD and SQL Server won't import the xml because it is a security risk. How can I enable DTD support on the database so it will let me insert the xml content.
推薦答案
你必須先CONVERT
.
MSDN一個>:
您可以使用以下命令從包含 DTD 的數據文件中導入 XML 數據OPENROWSET(BULK...) 函數,然后指定 CONVERT命令的 SELECT 子句中的選項.的基本語法命令是:
you can import XML data from a data file that contains a DTD by using the OPENROWSET(BULK...) function and then specifying the CONVERT option in the SELECT clause of the command. The basic syntax for the command is:
INSERT ... SELECT CONVERT(...) FROM OPENROWSET(BULK...)
示例:
INSERT T1
SELECT CONVERT(xml, BulkColumn, 2) FROM
OPENROWSET(Bulk 'c:\temp\Dtdfile.xml', SINGLE_BLOB) [rowsetresults];
這篇關于在 Sql Server 中啟用 DTD 支持的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!