﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Discuss Content Posted by Raj Vasant / Article Discussions / Article Discussions by Author  / Using OpenXML / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Wed, 22 May 2013 06:01:18 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Using OpenXML</title><link>http://www.sqlservercentral.com/Forums/Topic179995-227-1.aspx</link><description>Its all about how the columns in the with are matched when you don't specify an xpath literal i.ewith (name varchar(100)       ,age  int)With attribute centric mapping this will look for attributes of the elements matched in the OPENXML clause, i.e. @name and @age in  whereas element centric mapping looks at sub elements. i.e.  </description><pubDate>Thu, 05 Mar 2009 10:49:53 GMT</pubDate><dc:creator>Simon Sabin</dc:creator></item><item><title>RE: Using OpenXML</title><link>http://www.sqlservercentral.com/Forums/Topic179995-227-1.aspx</link><description>One thing about the article that I did not find clarification on was the difference between the flags 1 and 2: in bol it says if 1 used and combined with XML_Elements then attribute centric mapping is applied first and then the element centric mapping applied to those columns not handled while if 2 is used with XML_Attributes then attribute centric mapping is still applied first and then the element centric mapping is applied to the remaining columns not handled. I found this very odd and haven't found an explanation for this oddness- other places have kept repeating that. Can anyone clarify this?</description><pubDate>Thu, 05 Mar 2009 10:41:59 GMT</pubDate><dc:creator>zacmush</dc:creator></item><item><title>RE: Using OpenXML</title><link>http://www.sqlservercentral.com/Forums/Topic179995-227-1.aspx</link><description>Is "8 - Combined with XML_ATTRIBUTES or XML_ELEMENTS" the right parameter, i think this may be 3</description><pubDate>Fri, 21 Nov 2008 17:43:18 GMT</pubDate><dc:creator>Ronald Avendaño</dc:creator></item><item><title>RE: Using OpenXML</title><link>http://www.sqlservercentral.com/Forums/Topic179995-227-1.aspx</link><description>Excellent Article. Can u please tell about Image handling using BCP.It is really time consuming action to save the image in the db.</description><pubDate>Fri, 23 Feb 2007 20:30:00 GMT</pubDate><dc:creator>stephensunil</dc:creator></item><item><title>RE: Using OpenXML</title><link>http://www.sqlservercentral.com/Forums/Topic179995-227-1.aspx</link><description>&lt;P&gt;the reason we are using OPENXML in SQL Server 2000 is we get a list of integers from a source and we need to pass them into a stored procedure to be turned into a table to be joined with some destination table in order to filter out records that don't meet the search criteria. We cannot use comma-delimited strings since we never know how many values will be passed in. That's why we fomat integers as attributese and pass them as a text variable to a stored procedure which shreds the xml and inserts the field into a table variable. The problem we are having with OPENXML is poor response times when the number of records passed in is more than 150000. The following graph show how long (in seconds) it takes to obtain a hanle and open the document respectively.&lt;/P&gt;&lt;P&gt;&lt;TABLE style="WIDTH: 217pt; BORDER-COLLAPSE: collapse" cellSpacing=0 cellPadding=0 width=289 border=0 x:str&gt;&lt;COLGROUP&gt;&lt;COL style="WIDTH: 97pt; mso-width-source: userset; mso-width-alt: 4717" width=129&gt;&lt;COL style="WIDTH: 72pt; mso-width-source: userset; mso-width-alt: 3510" width=96&gt;&lt;COL style="WIDTH: 48pt" width=64&gt;&lt;TBODY&gt;&lt;TR style="HEIGHT: 45.75pt; mso-height-source: userset" height=61&gt;&lt;TD class=xl24 style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; WIDTH: 97pt; BORDER-BOTTOM: #ece9d8; HEIGHT: 45.75pt; BACKGROUND-COLOR: transparent" width=129 height=61&gt;&lt;FONT face=Arial size=2&gt;&lt;STRONG&gt;Number Of Records&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/TD&gt;&lt;TD class=xl24 style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; WIDTH: 72pt; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent" width=96&gt;&lt;FONT face=Arial size=2&gt;&lt;STRONG&gt;Obtain handle&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/TD&gt;&lt;TD class=xl24 style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; WIDTH: 48pt; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent" width=64&gt;&lt;STRONG&gt;&lt;FONT face=Arial size=2&gt;Open XML&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="HEIGHT: 12.75pt" height=17&gt;&lt;TD style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent" align=right height=17 x:num&gt;&lt;FONT face=Arial size=2&gt;300000&lt;/FONT&gt;&lt;/TD&gt;&lt;TD style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent" align=right x:num&gt;&lt;FONT face=Arial size=2&gt;15&lt;/FONT&gt;&lt;/TD&gt;&lt;TD style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent" align=right x:num&gt;&lt;FONT face=Arial size=2&gt;45&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="HEIGHT: 12.75pt" height=17&gt;&lt;TD style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent" align=right height=17 x:num&gt;&lt;FONT face=Arial size=2&gt;200000&lt;/FONT&gt;&lt;/TD&gt;&lt;TD style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent" align=right x:num&gt;&lt;FONT face=Arial size=2&gt;10&lt;/FONT&gt;&lt;/TD&gt;&lt;TD style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent" align=right x:num&gt;&lt;FONT face=Arial size=2&gt;25&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="HEIGHT: 12.75pt" height=17&gt;&lt;TD style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent" align=right height=17 x:num&gt;&lt;FONT face=Arial size=2&gt;100000&lt;/FONT&gt;&lt;/TD&gt;&lt;TD style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent" align=right x:num&gt;&lt;FONT face=Arial size=2&gt;5&lt;/FONT&gt;&lt;/TD&gt;&lt;TD style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent" align=right x:num&gt;&lt;FONT face=Arial size=2&gt;10&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="HEIGHT: 12.75pt" height=17&gt;&lt;TD style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent" align=right height=17 x:num&gt;&lt;FONT face=Arial size=2&gt;80000&lt;/FONT&gt;&lt;/TD&gt;&lt;TD style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent" align=right x:num&gt;&lt;FONT face=Arial size=2&gt;3&lt;/FONT&gt;&lt;/TD&gt;&lt;TD style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent" align=right x:num&gt;&lt;FONT face=Arial size=2&gt;8&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="HEIGHT: 12.75pt" height=17&gt;&lt;TD style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent" align=right height=17 x:num&gt;&lt;FONT face=Arial size=2&gt;40000&lt;/FONT&gt;&lt;/TD&gt;&lt;TD style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent" align=right x:num&gt;&lt;FONT face=Arial size=2&gt;2&lt;/FONT&gt;&lt;/TD&gt;&lt;TD style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent" align=right x:num&gt;&lt;FONT face=Arial size=2&gt;4&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="HEIGHT: 12.75pt" height=17&gt;&lt;TD style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent" align=right height=17 x:num&gt;&lt;FONT face=Arial size=2&gt;20000&lt;/FONT&gt;&lt;/TD&gt;&lt;TD style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent" align=right x:num&gt;&lt;FONT face=Arial size=2&gt;1.5&lt;/FONT&gt;&lt;/TD&gt;&lt;TD style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; BACKGROUND-COLOR: transparent" align=right x:num&gt;&lt;FONT face=Arial size=2&gt;2&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/P&gt;&lt;P&gt;I could not find any alternative in SQL Server 2000 to achive better results when dealing with big files except for saving it somewhere on a hard drive and using the file path and a bcp utility to load from a file.(I really do not want to do this).&lt;/P&gt;</description><pubDate>Fri, 23 Feb 2007 12:59:00 GMT</pubDate><dc:creator>latinsky</dc:creator></item><item><title>RE: Using OpenXML</title><link>http://www.sqlservercentral.com/Forums/Topic179995-227-1.aspx</link><description>&lt;P&gt;I found this article weak.  All information presented is available in the BOL.  So RTFM people.&lt;/P&gt;&lt;P&gt;I actually got more benefit by reading the comments posted about the article.  Specifically with respect to performance, using temp tables and releasing the xml document as early as possible.&lt;/P&gt;</description><pubDate>Fri, 23 Feb 2007 08:08:00 GMT</pubDate><dc:creator>Jonathan Scott-Sheldon</dc:creator></item><item><title>RE: Using OpenXML</title><link>http://www.sqlservercentral.com/Forums/Topic179995-227-1.aspx</link><description>&lt;P&gt;The parameter passed to the stored procedure can be assigned the XML file from the application.&lt;/P&gt;&lt;P&gt;For example: In .NET,&lt;/P&gt;&lt;P&gt;- Create a dataset.&lt;/P&gt;&lt;P&gt;- Get XML-string using the &amp;lt;DataSetName&amp;gt;.GetXml() function.&lt;/P&gt;&lt;P&gt;- Pass this XML-string to the procedure.&lt;/P&gt;</description><pubDate>Fri, 23 Feb 2007 00:13:00 GMT</pubDate><dc:creator>Vasant Raj</dc:creator></item><item><title>RE: Using OpenXML</title><link>http://www.sqlservercentral.com/Forums/Topic179995-227-1.aspx</link><description>SQL Server 2000 (not 2005) Question:Where you say, "Passing the XML document to the SQL server is just the same as passing any other text," for us new people, how do you pass any other text?I'm missing something here. I'm confused at how the data in an xml file, say c:\XMLDocs\MyData.xml in the file system somewhere, gets passed into the @strXML VARCHAR(2000) variable in Raj's example. Every example in every book I've seen (including BOL) shows the XML hard-coded into the sp_xml_preparedocument staement, which is of course worthless. Here's an example from BOL, Which shows the XML hard-coded in the SET @doc= statement (with leading "&lt;" symbols removed, so it will show up in the post):  declare @idoc int  declare @doc varchar(1000)  set @doc ="                     -- &lt;------- This part is what I'm talking about....   ROOT&gt;   Customers CustomerID="VINET" ContactName="Paul Henriot"&gt;     Orders CustomerID="VINET" EmployeeID="5" OrderDate="1996-07-04T00:00:00"&gt;        Order_x0020_Details OrderID="10248" ProductID="11" Quantity="12"/&gt;        Order_x0020_Details OrderID="10248" ProductID="42" Quantity="10"/&gt;     /Orders&gt;  /Customers&gt;  Customers CustomerID="LILAS" ContactName="Carlos Gonzlez"&gt;     Orders CustomerID="LILAS" EmployeeID="3" OrderDate="1996-08-16T00:00:00"&gt;        Order_x0020_Details OrderID="10283" ProductID="72" Quantity="3"/&gt;     /Orders&gt;  /Customers&gt;  /ROOT&gt;"  --Create an internal representation of the XML document.  exec sp_xml_preparedocument @idoc OUTPUT, @doc  -- SELECT statement using OPENXML rowset provider  SELECT    *  FROM       OPENXML (@idoc, '/ROOT/Customers')  EXEC sp_xml_removedocument @idocUsing a sproc to pass a varchar(2000) (or TEXT) variable sounds like a much better idea, but how do you load from the .XML file into the varchar(2000) variable, to pass into the sproc in the first place?Thanks...  </description><pubDate>Wed, 21 Feb 2007 13:58:00 GMT</pubDate><dc:creator>Arthur P. Jammz</dc:creator></item><item><title>RE: Using OpenXML</title><link>http://www.sqlservercentral.com/Forums/Topic179995-227-1.aspx</link><description>good article vasant You done a nice job</description><pubDate>Fri, 06 Oct 2006 00:29:00 GMT</pubDate><dc:creator>bijulsoni</dc:creator></item><item><title>RE: Using OpenXML</title><link>http://www.sqlservercentral.com/Forums/Topic179995-227-1.aspx</link><description>&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Verdana"&gt;Very good, well orgainzed article with everything needed for simple XML queries.&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Verdana"&gt;But it seems to me that responsible developers should avoid the temptation to use new technologies simply because of their &lt;EM&gt;cool &lt;/EM&gt;value. XML has its uses for hierarchical representation of data and as a communication format for web applications (because of firewall transparency). &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Verdana"&gt;However, for the examples provided in the original article, the equivalent code in T/SQL is much simpler and does not require the use of Temp tables (and thus tempdb) or table variables which have their own particular limitations. &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Verdana"&gt;In addition, for SQL Server 2000 applications XML is not optimized by the query optimizer and thus can be a performance liability depending on the complexity of the query. I don't know about 2005, but I assume that it's implementation is similar though query syntax is greatly simplified. &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Verdana"&gt;I would simply advise anyone thinking of using XML in SQL Server 2000 to do so for the right reasons and ensure that their code remains efficient, readable and maintainable. &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face="Souvenir Lt BT"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;</description><pubDate>Fri, 12 May 2006 13:04:00 GMT</pubDate><dc:creator>ThomasLN</dc:creator></item><item><title>RE: Using OpenXML</title><link>http://www.sqlservercentral.com/Forums/Topic179995-227-1.aspx</link><description>&lt;P&gt;hi,   &lt;/P&gt;&lt;P&gt;    Using Open XML was a article full of information. It was partucurly helpful for me because ur simple and easy to understand presentation.keep posting...&lt;/P&gt;</description><pubDate>Tue, 04 Apr 2006 08:03:00 GMT</pubDate><dc:creator>Gunjan Moghe</dc:creator></item><item><title>RE: Using OpenXML</title><link>http://www.sqlservercentral.com/Forums/Topic179995-227-1.aspx</link><description>&lt;P&gt;If you are interested in using OPENXML I strongly suggest that you get hold of a copy of &lt;A href="http://www.amazon.co.uk/exec/obidos/ASIN/1904347088/simonssql-21/203-0412052-6464708?creative=6394&amp;amp;camp=1406&amp;amp;link_code=as1"&gt;SQL Server XML Distilled&lt;/A&gt;. Why you may ask, well I wrote the OPENXML chapter. It covers, the pros and cons of element and attribute centric documents. Performance of using OPENXML relating to document size, attributes, namespaces.&lt;/P&gt;&lt;P&gt;There are lots of gotchas to be wary of, type casting, nulls, case sensitivity, use of complex xpath.&lt;/P&gt;&lt;P&gt;I also investigate the memory issue, its not as cut and dried as the 1/8th statement suggests, and generally depends on available memory at startup&lt;/P&gt;&lt;P&gt;You can't pass in a filename, but in 2005 you can read the contents of a file into an xml variable and then use that.&lt;/P&gt;&lt;P&gt;Passing the XML document to the SQL server is just the same as passing any other text. exec up_myXMLProc '&amp;lt;root&amp;gt;&amp;lt;element1&amp;gt;&amp;lt;/element1&amp;gt; ....&amp;lt;/root&amp;gt;', No clean up is neccesary except the use of sp_xml_removedocument, which should be called after every openxml call. &lt;/P&gt;&lt;P&gt;As for the benefits, the one is the saving of hierachical data, you only have to make one SP call rather than one for the parent and one for each child. These can be batched up which is why in testing both ways work out to be pretty much the same.&lt;/P&gt;&lt;P&gt;In 2005 the parser has been updated so you can use more xpath functions, in addition you can use xquery.&lt;/P&gt;&lt;P&gt;So lots of good things. &lt;/P&gt;</description><pubDate>Tue, 21 Feb 2006 15:44:00 GMT</pubDate><dc:creator>Simon Sabin</dc:creator></item><item><title>RE: Using OpenXML</title><link>http://www.sqlservercentral.com/Forums/Topic179995-227-1.aspx</link><description>&lt;DIV&gt;I don't understand the benefit outlined in the introduction.&lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;Even with SQL 6.5 you could have simply submitted the 100 insert statements in one big string and executed it (ADO/ASP/.Net has supported this for years). 1 trip, 100 records. The extra T-SQL involved should be the same size as the extra XML tags involved.&lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;i.e. cn.execute "INSERT Table VALUES ('Jim') INSERT Table VALUES ('Bob')"&lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;The non-XML method should also be easier because you don't need to figure out how to transfer the xml file to the other server (assuming the sql server was on a different machine then your code). Transferring one XML file is easy. Transferring multiple XML files due to multiple users/threads will have implications (not to mention cleanup). Why bother when there is no benefit?&lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;Of course, if you really needed to insert a LOT of records you wouldn't use either of these methods.&lt;/DIV&gt;</description><pubDate>Thu, 09 Jun 2005 21:31:00 GMT</pubDate><dc:creator>Jim-153675</dc:creator></item><item><title>RE: Using OpenXML</title><link>http://www.sqlservercentral.com/Forums/Topic179995-227-1.aspx</link><description>&lt;DIV&gt;&lt;FONT face=Arial size=2&gt;&lt;P&gt;Good job.&lt;/P&gt;&lt;P&gt;But in practical scenario where we have a huge data, say 2,000,000 records to be inserted into the database, the OpenXML command doesnt seem to be satisfactory.We are facing this problem where we have used this OpenXML which consumes about 15secs for inserting 65,000 records in a single user environment.When it is concurrent users, the performance of the entire system is poor.&lt;/P&gt;&lt;P&gt;We came across another component &lt;FONT face=Arial&gt;&lt;STRONG&gt;'XML Bulk Load Component'&lt;/STRONG&gt; for the same scenario.But wasnt able to proceed much on this.Would like to have comments from anyone who have knowledge on this.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face=Arial&gt;Thanks &amp;amp; Regards,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face=Arial&gt;Ramya&lt;/FONT&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;/DIV&gt;</description><pubDate>Thu, 02 Jun 2005 03:47:00 GMT</pubDate><dc:creator>Ramya-236512</dc:creator></item><item><title>RE: Using OpenXML</title><link>http://www.sqlservercentral.com/Forums/Topic179995-227-1.aspx</link><description>Well, if you can make it for one table, I can probably modify the Proc to handle any table.  Also, I can have the Proc auto-magically figure out the PKeys for the Table it's importing, so don't worry about that either.</description><pubDate>Fri, 13 May 2005 08:21:00 GMT</pubDate><dc:creator>tymberwyld</dc:creator></item><item><title>RE: Using OpenXML</title><link>http://www.sqlservercentral.com/Forums/Topic179995-227-1.aspx</link><description>&lt;P&gt;nice suggestion for using temp tables...&lt;/P&gt;&lt;P&gt;Its better to use them if the XML files are large...&lt;/P&gt;&lt;P&gt;If any exceptions occurs, temporary tables are not destroyed from the memory.&lt;/P&gt;&lt;P&gt;This can be a big problem.&lt;/P&gt;&lt;P&gt;Instead, one can use variable of TABLE Type.&lt;/P&gt;&lt;P&gt;thnx.&lt;/P&gt;</description><pubDate>Fri, 13 May 2005 04:19:00 GMT</pubDate><dc:creator>Vasant Raj</dc:creator></item><item><title>RE: Using OpenXML</title><link>http://www.sqlservercentral.com/Forums/Topic179995-227-1.aspx</link><description>&lt;P&gt;Tricky one...&lt;/P&gt;&lt;P&gt;i m working on it ... wait for some time &lt;img src='images/emotions/smile.gif' height='20' width='20' border='0' title='Smile' align='absmiddle'&gt;&lt;/P&gt;&lt;P&gt;Are you in need of a generic stored proc. (to insert data in any table) ???&lt;/P&gt;&lt;P&gt;If not, then solution is simple...&lt;/P&gt;</description><pubDate>Fri, 13 May 2005 04:11:00 GMT</pubDate><dc:creator>Vasant Raj</dc:creator></item><item><title>RE: Using OpenXML</title><link>http://www.sqlservercentral.com/Forums/Topic179995-227-1.aspx</link><description>That's good to know. We were doing it for performance reasons, not because of failures in the code, but if we dodged a bullet, so much the better.</description><pubDate>Thu, 12 May 2005 11:28:00 GMT</pubDate><dc:creator>Grant Fritchey</dc:creator></item><item><title>RE: Using OpenXML</title><link>http://www.sqlservercentral.com/Forums/Topic179995-227-1.aspx</link><description>&lt;P&gt;Just to clarify:&lt;/P&gt;&lt;P&gt;In our case we were calling sp_xml_removedocument EVERY time. The problem we ran into is not from the orphans, but from repeated selects from the xml. So, I agree that it's vital to call sp_xml_removedocument everytime, but it's also vital to only make a limited number of selects directly from the xml, which BOL doesn't emphasis enough. Also, the problem we ran into wasn't a server crash, just an unexpected failure of stored proccedure. &lt;/P&gt;&lt;P&gt;Like you, our practice now is to make only one select against the xml - so you can get it into a temp table or table variable, then close it. &lt;/P&gt;&lt;P&gt;I just wanted to mention this so others don't have to go thru the headache I went thru.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description><pubDate>Thu, 12 May 2005 10:47:00 GMT</pubDate><dc:creator>rhein</dc:creator></item><item><title>RE: Using OpenXML</title><link>http://www.sqlservercentral.com/Forums/Topic179995-227-1.aspx</link><description>&lt;P&gt;Yes, it is &lt;STRONG&gt;critically&lt;/STRONG&gt; important to call sp_xml_removedocument. The statement in the article "&lt;EM&gt;This handle is valid for until the connection is reset, or until the execution of sp_xml_removedocument.&lt;/EM&gt;" is correct but does not mention the bug you ran into. If you do not call sp_xml_removedocument the handle is orphaned and will not be released. Overtime your handle count is going to increase and your server will eventually crash. (You can watch the handle count increase for sqlservr.exe by using the process tab of the task manager and adding the column for handles.)&lt;/P&gt;&lt;P&gt;Therefore our standard is to read the xml document into a temp table and immediately call sp_xml_removedocument before there is a chance to orphan the handle.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description><pubDate>Thu, 12 May 2005 10:32:00 GMT</pubDate><dc:creator>Michael Rauch</dc:creator></item><item><title>RE: Using OpenXML</title><link>http://www.sqlservercentral.com/Forums/Topic179995-227-1.aspx</link><description>&lt;P&gt;A followup to you your comment about &lt;HR&gt;&lt;/P&gt;&lt;P&gt;"Generally, if we run into a situation where the XML is used in more than a single statement, we load the data into a temp table and close the document as soon as possible before doing more processing"&lt;HR&gt;&lt;/P&gt;&lt;P&gt;It is  &lt;STRONG&gt;&lt;U&gt;CRITICALLY&lt;/U&gt;&lt;/STRONG&gt; important to do this. There is actually a bug in OpenXML that will cause you to get unexpected crashes when you use the OpenXML over and over.  It might not bite you every time, but I've had first hand experience with it. &lt;/P&gt;&lt;P&gt;We had an application that we used OpenXml with in testing. The stored proceedure had been finished and had been working for 6 months when one day, the stored proccedure starte crashing for NO reason. - The XML was valid, and had worked the day before, and nothing had changed, but it simply started crashing. A consultant who was working with us, who had worked in the SQL group at Microsoft said that he had seen that before, and to do the OpenXML, get the data into table variables, and close the xml as quickly as possible. We ended up implimenting that change, which was fairly trivial and poof - the problem disappeared as quickly as it had appeared. I seem to recall that the root of the problem was a memory leak in the OpenXML code.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description><pubDate>Thu, 12 May 2005 09:25:00 GMT</pubDate><dc:creator>rhein</dc:creator></item><item><title>RE: Using OpenXML</title><link>http://www.sqlservercentral.com/Forums/Topic179995-227-1.aspx</link><description>Could someone give me an example of how I might be able to import an XML Doc that has this structure?  I currently use this structure when Exporting / Importing data from any table in my DB.  It's simple and understandable.  Sometimes, this file can be about 50MB though.  How would that be possible using a Stored Proc?&amp;lt;DATASOURCE Name="Users"&amp;gt;    &amp;lt;ROW&amp;gt;		&amp;lt;COLUMN Name="ID"&amp;gt;&amp;lt;![CDATA[1]]&amp;gt;&amp;lt;/COLUMN&amp;gt;		&amp;lt;COLUMN Name="FirstName"&amp;gt;&amp;lt;![CDATA[George]]&amp;gt;&amp;lt;/COLUMN&amp;gt;		&amp;lt;COLUMN Name="LastName"&amp;gt;&amp;lt;![CDATA[Wilson]]&amp;gt;&amp;lt;/COLUMN&amp;gt;	&amp;lt;/ROW&amp;gt;	&amp;lt;ROW&amp;gt;		&amp;lt;COLUMN Name="ID"&amp;gt;&amp;lt;![CDATA[2]]&amp;gt;&amp;lt;/COLUMN&amp;gt;		&amp;lt;COLUMN Name="FirstName"&amp;gt;&amp;lt;![CDATA[Martha]]&amp;gt;&amp;lt;/COLUMN&amp;gt;		&amp;lt;COLUMN Name="LastName"&amp;gt;&amp;lt;![CDATA[Wilson]]&amp;gt;&amp;lt;/COLUMN&amp;gt;	&amp;lt;/ROW&amp;gt;&amp;lt;/DATASOURCE&amp;gt;</description><pubDate>Thu, 12 May 2005 07:38:00 GMT</pubDate><dc:creator>tymberwyld</dc:creator></item><item><title>RE: Using OpenXML</title><link>http://www.sqlservercentral.com/Forums/Topic179995-227-1.aspx</link><description>&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;&lt;P&gt;"can we also use a path where the XML file exists."&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P dir=ltr&gt;I'm pretty sure that you can't reference files directly from within TSQL. If you really, really HAD to do this, you have to open a command shell and/or create objects with sp_oa* procedures. I'd strongly recommend against both. They're basically stepping outside of the realm where TSQL peforms consistently and well.&lt;/P&gt;&lt;P dir=ltr&gt;You know that you can pass procedures a TEXT data type so that you're not limited by the 8K of varchar (or 4k of nvarchar)? That's how we do it now. If you have to load really huge files, instead of using OPENXML, look into XML Bulk load in BOL.&lt;/P&gt;</description><pubDate>Thu, 12 May 2005 07:28:00 GMT</pubDate><dc:creator>Grant Fritchey</dc:creator></item><item><title>RE: Using OpenXML</title><link>http://www.sqlservercentral.com/Forums/Topic179995-227-1.aspx</link><description>&lt;P&gt;Good Article Vasant, wrote in a very simple and easy way.&lt;/P&gt;&lt;P&gt;I have one doubt here about  sp_xml_preparedocument.&lt;/P&gt;&lt;P&gt;In BOL and also in the mentioned article XML document/content is assigning to a varchar variable and using in sp_xml_preparedocument. Instead of using the variable, can we also use a path where the XML file exists. If so how do we need to mention.&lt;/P&gt;&lt;P&gt;Can any one help regarding this with a simple syntax?&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Subhash&lt;/P&gt;</description><pubDate>Thu, 12 May 2005 07:12:00 GMT</pubDate><dc:creator>Subhash-141882</dc:creator></item><item><title>RE: Using OpenXML</title><link>http://www.sqlservercentral.com/Forums/Topic179995-227-1.aspx</link><description>&lt;P&gt;Nice article.&lt;/P&gt;&lt;P&gt;You might consider adding information about performance management. For example, maintaining the document handle across multiple queries and/or procedure calls is pretty expensive. Generally, if we run into a situation where the XML is used in more than a single statement, we load the data into a temp table and close the document as soon as possible before doing more processing. It shows quite a performance improvement.&lt;/P&gt;&lt;P&gt;Also, another performance issue, we found that element centric XML code is pretty fat, causing more networking and memory issues(every column has &amp;lt;dude&amp;gt;&amp;lt;/dude&amp;gt; as well as the data as well as the rows). As a standard in our organization we use attribute centric (where columns get @dude="", reducing the file size and memory footprint considerably).&lt;/P&gt;&lt;P&gt;Excellently written.&lt;/P&gt;</description><pubDate>Thu, 12 May 2005 06:29:00 GMT</pubDate><dc:creator>Grant Fritchey</dc:creator></item><item><title>RE: Using OpenXML</title><link>http://www.sqlservercentral.com/Forums/Topic179995-227-1.aspx</link><description>Thought this was great myself, keep em coming!</description><pubDate>Thu, 12 May 2005 05:17:00 GMT</pubDate><dc:creator>vickster</dc:creator></item><item><title>RE: Using OpenXML</title><link>http://www.sqlservercentral.com/Forums/Topic179995-227-1.aspx</link><description>Good Article!!..Simple presentation....Keep it up..</description><pubDate>Wed, 11 May 2005 23:51:00 GMT</pubDate><dc:creator>Agson Chellakudam</dc:creator></item><item><title>Using OpenXML</title><link>http://www.sqlservercentral.com/Forums/Topic179995-227-1.aspx</link><description>Comments posted to this topic are about the content posted at &lt;A HREF="http://www.sqlservercentral.com/columnists/rVasant/usingopenxml.asp"&gt;http://www.sqlservercentral.com/columnists/rVasant/usingopenxml.asp&lt;/A&gt;</description><pubDate>Wed, 04 May 2005 15:04:00 GMT</pubDate><dc:creator>Vasant Raj</dc:creator></item></channel></rss>