sql-server-openxml

Parsing OpenXML with multiple elements of the same name

与世无争的帅哥 提交于 2019-12-18 06:48:57
问题 I have a data structure as such: <rootnode> <group> <id>1</id> <anothernode>first string</anothernode> <anothernode>second string</anothernode> </group> <group> <id>2</id> <anothernode>third string</anothernode> <anothernode>fourth string</anothernode> </group> </rootnode> And the following code: EXEC sp_xml_preparedocument @index OUTPUT, @XMLdoc SELECT * FROM OPENXML (@index, 'rootnode/group') WITH ( id int 'id', anothernode varchar(30) 'anothernode' ) which gives me the result id |

SQL Server query XML datatype performance issue

隐身守侯 提交于 2019-12-11 06:54:29
问题 I have a XML file stored in a XML datatype column data in my table records . The table looks like this: create table records ( id int, type nvarchar(28), data xml, posted datetime ) XML data: <Properties> <data> <Name>novel</Name> <Gender>Female</Gender> <Age>32</Age> <Salary>55k</Salary> <Phone>123-123</Phone> </data> </Properties> I am currently using following query to extract data from that XML column which is taking more than minutes in 20K records. select id, posteddate, CONVERT(

Generating docx file from HTML file using OpenXML

前提是你 提交于 2019-12-04 17:51:16
I'm using this method for generating docx file: public static void CreateDocument(string documentFileName, string text) { using (WordprocessingDocument wordDoc = WordprocessingDocument.Create(documentFileName, WordprocessingDocumentType.Document)) { MainDocumentPart mainPart = wordDoc.AddMainDocumentPart(); string docXml = @"<?xml version=""1.0"" encoding=""UTF-8"" standalone=""yes""?> <w:document xmlns:w=""http://schemas.openxmlformats.org/wordprocessingml/2006/main""> <w:body><w:p><w:r><w:t>#REPLACE#</w:t></w:r></w:p></w:body> </w:document>"; docXml = docXml.Replace("#REPLACE#", text); using

Parsing OpenXML with multiple elements of the same name

可紊 提交于 2019-11-29 11:28:31
I have a data structure as such: <rootnode> <group> <id>1</id> <anothernode>first string</anothernode> <anothernode>second string</anothernode> </group> <group> <id>2</id> <anothernode>third string</anothernode> <anothernode>fourth string</anothernode> </group> </rootnode> And the following code: EXEC sp_xml_preparedocument @index OUTPUT, @XMLdoc SELECT * FROM OPENXML (@index, 'rootnode/group') WITH ( id int 'id', anothernode varchar(30) 'anothernode' ) which gives me the result id | anothernode ———————————————— 1 | first string 2 | third string How can I get it to show this result instead