How to import XML from Data Dictionary to SQL Server?

3

To contextualize, I'm doing a data dictionary for a local database, for that I used a tool called "DataBase NoteTaker".

This tool loads the data from the database and allows me to comment on the data in the tables and saves the changes to the XML file. File extenso para por no texto, it's available Here.

Firstly, I need to know if you can import these types of data into SQL Server. If so, how do I import this?

    
asked by anonymous 29.11.2017 / 16:44

1 answer

2

Yes, you can do the following:

CREATE TABLE XMLwithOpenXML
(
Id INT IDENTITY PRIMARY KEY,
XMLData XML,
LoadedDateTime DATETIME
)


INSERT INTO XMLwithOpenXML(XMLData, LoadedDateTime)
SELECT CONVERT(XML, BulkColumn) AS BulkColumn, GETDATE() 
FROM OPENROWSET(BULK 'c:\seuarquivo.xml', SINGLE_BLOB) AS x;


SELECT * FROM XMLwithOpenXML

Once you have done this, you will create a table to store the contents of your XML. Now to read this content I made a test with your file:

DECLARE @XML AS XML, @hDoc AS INT, @SQL NVARCHAR (MAX)

SELECT @XML = XMLData FROM XMLwithOpenXML

EXEC sp_xml_preparedocument @hDoc OUTPUT, @XML

select @xml
SELECT [Key], [Value]
FROM OPENXML(@hDoc, 'DatabaseNoteTakerProject/Project/Setting')
WITH 
(
[key] [varchar](50) '@key',
[value] [varchar](100) '@value'
)

EXEC sp_xml_removedocument @hDoc
GO

I got as a result: (which are part of your XML)

  

saveConnectionSettingsSeparately False

     

saveOneFilePerObject False

     

saveObjectHistory True

     

publishPath

     

publishXSLPath

     

includeFilter NULL

     

excludeFilter NULL

More information and details can be found here:

>

    
03.12.2017 / 13:51