David James Ball
David James Ball

Reputation: 913

Enabling DTD support in Sql Server

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.

Upvotes: 2

Views: 2053

Answers (1)

Zanon
Zanon

Reputation: 30770

You have to CONVERT it first.

MSDN:

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...)

Example:

INSERT T1
  SELECT CONVERT(xml, BulkColumn, 2) FROM 
    OPENROWSET(Bulk 'c:\temp\Dtdfile.xml', SINGLE_BLOB) [rowsetresults];

Upvotes: 1

Related Questions