Questions tagged [sql-server-openxml]

OPENXML is a SQL Server keyword that provides a rowset over in-memory XML documents which can be treated like a table or a view.

OPENXML, a Transact-SQL keyword, provides a rowset over in-memory XML documents that is similar to a table or a view. OPENXML allows access to XML data as though it is a relational rowset. It does this by providing a rowset view of the internal representation of an XML document. The records in the rowset can be stored in database tables.

OPENXML can be used in SELECT and SELECT INTO statements wherever rowset providers, a view, or OPENROWSET can appear as the source. For information about the syntax , see OPENXML (Transact-SQL).

To write queries against an XML document by using OPENXML, you must first call sp_xml_preparedocument. This parses the XML document and returns a handle to the parsed document that is ready for consumption. The parsed document is a document object model (DOM) tree representation of various nodes in the XML document. The document handle is passed to OPENXML, which then provides a rowset view of the document based on the parameters passed to it.

Source: Microsoft (OPENXML Keyword)

55 questions
16
votes
4 answers

SQL OpenXML Multiple Tag Issue

I am just new to reading in an XML file into a table through SQL Server Management Studio. There are probably better ways but I would like to use this approach. Currently I am reading in a standard XML file of records on people. A tag is…
user3441467
  • 161
  • 6
6
votes
1 answer

Parsing OpenXML with multiple elements of the same name

I have a data structure as such: 1 first string second string 2 third string
MSpeed
  • 8,153
  • 7
  • 49
  • 61
5
votes
3 answers

Generating docx file from HTML file using OpenXML

I'm using this method for generating docx file: public static void CreateDocument(string documentFileName, string text) { using (WordprocessingDocument wordDoc = WordprocessingDocument.Create(documentFileName,…
newbie
  • 273
  • 2
  • 4
  • 13
4
votes
1 answer

OPENXML import xml to ms sql - namespace

I used this site for a long time, and many times it helped me in solving various problems. This time i'm stuck. I try to import a complex xml like the one bellow into ms-sql table.
2
votes
2 answers

convert sql xml datatype to table

Given the SQL... declare @xmlDoc xml set @xmlDoc = '
John Livermore
  • 30,235
  • 44
  • 126
  • 216
2
votes
1 answer

BULK INSERT using XML

I am unable to write a stored procedure for bulk insertion into my table. I want to insert list of into [tbl_ReleaseHistory] keeping null. Also while inserting into the same table should remain null. I…
2
votes
1 answer

Is @mp:id always in order of the XML Doc?

I am parsing some xml using OPENXML. I need to get an Identity off of the XML to know the order of the nodes. is @mp:id always in order? I know they are not sequential, but are they at least in order? For example would the following query always…
Vaccano
  • 78,325
  • 149
  • 468
  • 850
2
votes
2 answers

XML to SQL Issue

I am trying to parse a sample xml , but I am not getting expected output , I am using openxml to do this : This is the code : declare @myxml xml = '
user7739833
2
votes
1 answer

MS SQL Server - OpenXML - Multiple elements

XML example: 1 2 I want to select both Risk elements with this query: SELECT RISK FROM…
chaika_sv
  • 384
  • 1
  • 4
  • 16
2
votes
2 answers

Dynamic columns and records from openxml in sql

I have an xml document that's pretty straightfoward. The only difference is that the elements can change. One time I might…
1
vote
1 answer

Inserting a constant/variable along with XML in SQL Server 2008

I'm sure this has been answered before but I can't find the right nomenclature to find the answer. Basically, I have a very simple table with 2 columns, both of data type int Now, I'm trying to insert n records into the table with one of the columns…
1
vote
1 answer

Sql Server deadlock error when performing multiple Inserts within a stored procedure

I am running into a deadlock issue when my stored procedure is called in sql server 2008. an xml string is passed into the stored procedure by biztalk and can be called many times in quick succession. The problem I am running into is that if the…
gyochum
  • 131
  • 4
  • 12
1
vote
0 answers

Programmatically Refresh Excel Data Connections Without Interop

I need to programmatically refresh Excel data connections without Interop in VB.Net code. I am somewhat familiar with Open XML and how to create or modify spreadsheets, but I can't figure out how to just refresh the data (from SQL-Server) using…
rspiet
  • 11
  • 1
1
vote
0 answers

SQL Server OPENXML v XQUERY Performance

I've been testing both OpenXML and XQuery and OpenXML is out performing XQuery by a lot (I believe it should be the other way around from what I have been reading) I prefer to use XQuery so I'm looking for some help. Any way to improve the Xquery? I…
DC07
  • 293
  • 5
  • 18
1
vote
2 answers

Need to parse the XML using OPENXML with Attributes and Elements

I am facing an issue while parsing the XML elements and attributes in SQL Server.
1
2 3 4