<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: SQL SERVER &#8211; Simple Example of Reading XML File Using T-SQL</title>
	<atom:link href="http://blog.sqlauthority.com/2009/02/13/sql-server-simple-example-of-reading-xml-file-using-t-sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2009/02/13/sql-server-simple-example-of-reading-xml-file-using-t-sql/</link>
	<description>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Sun, 12 Feb 2012 09:22:39 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: ram</title>
		<link>http://blog.sqlauthority.com/2009/02/13/sql-server-simple-example-of-reading-xml-file-using-t-sql/#comment-250820</link>
		<dc:creator><![CDATA[ram]]></dc:creator>
		<pubDate>Fri, 10 Feb 2012 05:51:52 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2468#comment-250820</guid>
		<description><![CDATA[Dear 

i have one employee table in xml 
how to display the all records from xml
like(select *from emp)]]></description>
		<content:encoded><![CDATA[<p>Dear </p>
<p>i have one employee table in xml<br />
how to display the all records from xml<br />
like(select *from emp)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER &#8211; Methods for Accessing SQL Server XML Datatype &#8211; Quiz &#8211; Puzzle &#8211; 20 of 31 &#171; SQL Server Journey with SQL Authority</title>
		<link>http://blog.sqlauthority.com/2009/02/13/sql-server-simple-example-of-reading-xml-file-using-t-sql/#comment-241554</link>
		<dc:creator><![CDATA[SQL SERVER &#8211; Methods for Accessing SQL Server XML Datatype &#8211; Quiz &#8211; Puzzle &#8211; 20 of 31 &#171; SQL Server Journey with SQL Authority]]></dc:creator>
		<pubDate>Sat, 21 Jan 2012 01:31:44 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2468#comment-241554</guid>
		<description><![CDATA[[...] SELECT * FROM XML Shredding XML Validate an XML document in TSQL using XSD Simple Example of Reading XML File Using T-SQL Simple Example of Creating XML File Using [...]]]></description>
		<content:encoded><![CDATA[<p>[...] SELECT * FROM XML Shredding XML Validate an XML document in TSQL using XSD Simple Example of Reading XML File Using T-SQL Simple Example of Creating XML File Using [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: vasu</title>
		<link>http://blog.sqlauthority.com/2009/02/13/sql-server-simple-example-of-reading-xml-file-using-t-sql/#comment-241393</link>
		<dc:creator><![CDATA[vasu]]></dc:creator>
		<pubDate>Fri, 20 Jan 2012 17:45:16 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2468#comment-241393</guid>
		<description><![CDATA[
          
                
                
                
                
                
           
        
Sir

Help me in getting the text of a particular value attribute]]></description>
		<content:encoded><![CDATA[<p>Sir</p>
<p>Help me in getting the text of a particular value attribute</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Akhil</title>
		<link>http://blog.sqlauthority.com/2009/02/13/sql-server-simple-example-of-reading-xml-file-using-t-sql/#comment-211785</link>
		<dc:creator><![CDATA[Akhil]]></dc:creator>
		<pubDate>Tue, 06 Dec 2011 03:33:40 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2468#comment-211785</guid>
		<description><![CDATA[DECLARE @productIds xml
SET @productIds =&#039;3615&#039; 

SELECT
ParamValues.ID.value(&#039;.&#039;,&#039;VARCHAR(20)&#039;)
FROM @productIds.nodes(&#039;/Products/id&#039;) as ParamValues(ID)]]></description>
		<content:encoded><![CDATA[<p>DECLARE @productIds xml<br />
SET @productIds =&#8217;3615&#8242; </p>
<p>SELECT<br />
ParamValues.ID.value(&#8216;.&#8217;,'VARCHAR(20)&#8217;)<br />
FROM @productIds.nodes(&#8216;/Products/id&#8217;) as ParamValues(ID)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: penolepe</title>
		<link>http://blog.sqlauthority.com/2009/02/13/sql-server-simple-example-of-reading-xml-file-using-t-sql/#comment-202252</link>
		<dc:creator><![CDATA[penolepe]]></dc:creator>
		<pubDate>Tue, 22 Nov 2011 15:05:29 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2468#comment-202252</guid>
		<description><![CDATA[you are perfect. very thanks.]]></description>
		<content:encoded><![CDATA[<p>you are perfect. very thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: S.L.</title>
		<link>http://blog.sqlauthority.com/2009/02/13/sql-server-simple-example-of-reading-xml-file-using-t-sql/#comment-177203</link>
		<dc:creator><![CDATA[S.L.]]></dc:creator>
		<pubDate>Mon, 10 Oct 2011 15:52:46 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2468#comment-177203</guid>
		<description><![CDATA[So, where is the code to actually read XML from a *FILE* -- The title says &quot;example of reading xml file&quot; but I see nothing about how to open and read data from an XML file on disk??]]></description>
		<content:encoded><![CDATA[<p>So, where is the code to actually read XML from a *FILE* &#8212; The title says &#8220;example of reading xml file&#8221; but I see nothing about how to open and read data from an XML file on disk??</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Effle</title>
		<link>http://blog.sqlauthority.com/2009/02/13/sql-server-simple-example-of-reading-xml-file-using-t-sql/#comment-175721</link>
		<dc:creator><![CDATA[John Effle]]></dc:creator>
		<pubDate>Thu, 06 Oct 2011 13:39:23 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2468#comment-175721</guid>
		<description><![CDATA[Thank you Mr. Pinal]]></description>
		<content:encoded><![CDATA[<p>Thank you Mr. Pinal</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dann</title>
		<link>http://blog.sqlauthority.com/2009/02/13/sql-server-simple-example-of-reading-xml-file-using-t-sql/#comment-166879</link>
		<dc:creator><![CDATA[dann]]></dc:creator>
		<pubDate>Fri, 09 Sep 2011 18:09:38 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2468#comment-166879</guid>
		<description><![CDATA[hi, pueden ayudarme se los voy a agradecer mucho.

how create schema for this xml?



   
      
         
            2345345
            345
            04/25/2011
            09:12 am
         
      
   
]]></description>
		<content:encoded><![CDATA[<p>hi, pueden ayudarme se los voy a agradecer mucho.</p>
<p>how create schema for this xml?</p>
<p>            2345345<br />
            345<br />
            04/25/2011<br />
            09:12 am</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dinesh singu</title>
		<link>http://blog.sqlauthority.com/2009/02/13/sql-server-simple-example-of-reading-xml-file-using-t-sql/#comment-163898</link>
		<dc:creator><![CDATA[dinesh singu]]></dc:creator>
		<pubDate>Wed, 31 Aug 2011 08:48:48 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2468#comment-163898</guid>
		<description><![CDATA[sir I need help for inserting muliple rows in table
for 100 colours then I have to folowing
a.b.value(‘Colors[1]/Color1[1]‘,‘varchar(10)’) AS Color1,
a.b.value(‘Colors[1]/Color2[1]‘,‘varchar(10)’) AS Color2,
                             ........
                                 ......
                                    .......
a.b.value(‘Colors[1]/Color1[100]‘,‘varchar(10)’) AS Color1,
this much code we have.we have any option to write in 2 or 3 lines 
pls help me .mail me on [email removed]]]></description>
		<content:encoded><![CDATA[<p>sir I need help for inserting muliple rows in table<br />
for 100 colours then I have to folowing<br />
a.b.value(‘Colors[1]/Color1[1]‘,‘varchar(10)’) AS Color1,<br />
a.b.value(‘Colors[1]/Color2[1]‘,‘varchar(10)’) AS Color2,<br />
                             &#8230;&#8230;..<br />
                                 &#8230;&#8230;<br />
                                    &#8230;&#8230;.<br />
a.b.value(‘Colors[1]/Color1[100]‘,‘varchar(10)’) AS Color1,<br />
this much code we have.we have any option to write in 2 or 3 lines<br />
pls help me .mail me on [email removed]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dinesh singu</title>
		<link>http://blog.sqlauthority.com/2009/02/13/sql-server-simple-example-of-reading-xml-file-using-t-sql/#comment-163896</link>
		<dc:creator><![CDATA[dinesh singu]]></dc:creator>
		<pubDate>Wed, 31 Aug 2011 08:42:26 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2468#comment-163896</guid>
		<description><![CDATA[hello give proper single quotes]]></description>
		<content:encoded><![CDATA[<p>hello give proper single quotes</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sharon</title>
		<link>http://blog.sqlauthority.com/2009/02/13/sql-server-simple-example-of-reading-xml-file-using-t-sql/#comment-155715</link>
		<dc:creator><![CDATA[sharon]]></dc:creator>
		<pubDate>Wed, 10 Aug 2011 08:27:05 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2468#comment-155715</guid>
		<description><![CDATA[Hi Mr. Pinal,
How can i show the following xml in select view
thanks 
sharon

declare @xml xml
set @xml = 
User ID=25
   SecurityLevelID  222  SecurityLevelID
    SecurityLevelID 223  SecurityLevelID
    SecurityLevelID 224  SecurityLevelID
UserID

result :
SecurityLevelID   ID 
222                       25
223                       25
224                       25]]></description>
		<content:encoded><![CDATA[<p>Hi Mr. Pinal,<br />
How can i show the following xml in select view<br />
thanks<br />
sharon</p>
<p>declare @xml xml<br />
set @xml =<br />
User ID=25<br />
   SecurityLevelID  222  SecurityLevelID<br />
    SecurityLevelID 223  SecurityLevelID<br />
    SecurityLevelID 224  SecurityLevelID<br />
UserID</p>
<p>result :<br />
SecurityLevelID   ID<br />
222                       25<br />
223                       25<br />
224                       25</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sharon</title>
		<link>http://blog.sqlauthority.com/2009/02/13/sql-server-simple-example-of-reading-xml-file-using-t-sql/#comment-155713</link>
		<dc:creator><![CDATA[sharon]]></dc:creator>
		<pubDate>Wed, 10 Aug 2011 08:24:32 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2468#comment-155713</guid>
		<description><![CDATA[Hi Mr. Pinal,
How can i show the following xml in select view
thanks 
sharon

declare @xml xml
set @xml = 
&#039;
    222
    223
    224
&#039;

result :
SecurityLevelID   ID 
222                       25
223                       25
224                       25]]></description>
		<content:encoded><![CDATA[<p>Hi Mr. Pinal,<br />
How can i show the following xml in select view<br />
thanks<br />
sharon</p>
<p>declare @xml xml<br />
set @xml =<br />
&#8216;<br />
    222<br />
    223<br />
    224<br />
&#8216;</p>
<p>result :<br />
SecurityLevelID   ID<br />
222                       25<br />
223                       25<br />
224                       25</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sabeer</title>
		<link>http://blog.sqlauthority.com/2009/02/13/sql-server-simple-example-of-reading-xml-file-using-t-sql/#comment-151595</link>
		<dc:creator><![CDATA[Sabeer]]></dc:creator>
		<pubDate>Fri, 29 Jul 2011 15:11:28 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2468#comment-151595</guid>
		<description><![CDATA[Hi Sir,

I have XML that is in the Format   

    
      
        contractTypeId
        15
      
      
        endDate
        J
      
      
        startDate
        03/01/2004
      
      
        restrictedService
        False
      
      
        requestType
        R
      
      
        requestTypeId
        4
      
      
        contractAmount
        $10.00
      
      
        versionNo
        1
      
      
        listId
        249
      
      
        changeOrderId
        -1
      
      
        supplementNo
        0
      
      
        templateId
        19
      
      
        requestDocId
        224
      
      
        requestId
        234
      
      
        orgUnitTemplateId
        19
      
      
        contractTypeRequired
        False
      
      
        EndDate
        31/03/2011
      
    
  

it&#039;s required for me to update the Only startdate  and EndDate  values with new dates. Please help me on this ?]]></description>
		<content:encoded><![CDATA[<p>Hi Sir,</p>
<p>I have XML that is in the Format   </p>
<p>        contractTypeId<br />
        15</p>
<p>        endDate<br />
        J</p>
<p>        startDate<br />
        03/01/2004</p>
<p>        restrictedService<br />
        False</p>
<p>        requestType<br />
        R</p>
<p>        requestTypeId<br />
        4</p>
<p>        contractAmount<br />
        $10.00</p>
<p>        versionNo<br />
        1</p>
<p>        listId<br />
        249</p>
<p>        changeOrderId<br />
        -1</p>
<p>        supplementNo<br />
        0</p>
<p>        templateId<br />
        19</p>
<p>        requestDocId<br />
        224</p>
<p>        requestId<br />
        234</p>
<p>        orgUnitTemplateId<br />
        19</p>
<p>        contractTypeRequired<br />
        False</p>
<p>        EndDate<br />
        31/03/2011</p>
<p>it&#8217;s required for me to update the Only startdate  and EndDate  values with new dates. Please help me on this ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Jacobson</title>
		<link>http://blog.sqlauthority.com/2009/02/13/sql-server-simple-example-of-reading-xml-file-using-t-sql/#comment-149418</link>
		<dc:creator><![CDATA[John Jacobson]]></dc:creator>
		<pubDate>Tue, 19 Jul 2011 22:07:51 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2468#comment-149418</guid>
		<description><![CDATA[Thanks so much for your clear concise examples!!  You are a life saver.]]></description>
		<content:encoded><![CDATA[<p>Thanks so much for your clear concise examples!!  You are a life saver.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vinod</title>
		<link>http://blog.sqlauthority.com/2009/02/13/sql-server-simple-example-of-reading-xml-file-using-t-sql/#comment-144252</link>
		<dc:creator><![CDATA[Vinod]]></dc:creator>
		<pubDate>Mon, 27 Jun 2011 20:25:38 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2468#comment-144252</guid>
		<description><![CDATA[Sample file once again the sample file.



27/06/2011
123456789
1234
CCODE001
CUSTOMER NAME
N

REC ADDR 1
REC ADDR 2



WORLD

SENDER NAME

SEND ADDR 1
SEND ADDR 2
SEND ADDR 3
STATE
POSTCODE


S
CARRIER NAME
999123
BY ROAD
N





6
18
0
0
0

N



10.00
11.00
0
11.00
11.00
0
11.00
11.00
1

N

N






ABCDEFGHIJ000000990001
ABCDEFGHIJ000000990002
0

T000123
CUSTOMER
6
6


]]></description>
		<content:encoded><![CDATA[<p>Sample file once again the sample file.</p>
<p>27/06/2011<br />
123456789<br />
1234<br />
CCODE001<br />
CUSTOMER NAME<br />
N</p>
<p>REC ADDR 1<br />
REC ADDR 2</p>
<p>WORLD</p>
<p>SENDER NAME</p>
<p>SEND ADDR 1<br />
SEND ADDR 2<br />
SEND ADDR 3<br />
STATE<br />
POSTCODE</p>
<p>S<br />
CARRIER NAME<br />
999123<br />
BY ROAD<br />
N</p>
<p>6<br />
18<br />
0<br />
0<br />
0</p>
<p>N</p>
<p>10.00<br />
11.00<br />
0<br />
11.00<br />
11.00<br />
0<br />
11.00<br />
11.00<br />
1</p>
<p>N</p>
<p>N</p>
<p>ABCDEFGHIJ000000990001<br />
ABCDEFGHIJ000000990002<br />
0</p>
<p>T000123<br />
CUSTOMER<br />
6<br />
6</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vinod</title>
		<link>http://blog.sqlauthority.com/2009/02/13/sql-server-simple-example-of-reading-xml-file-using-t-sql/#comment-144250</link>
		<dc:creator><![CDATA[Vinod]]></dc:creator>
		<pubDate>Mon, 27 Jun 2011 20:19:43 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2468#comment-144250</guid>
		<description><![CDATA[Below is the sample xml file
-----------------------------------------------------------------------------------

- - 27/06/2011 123456789 7372 CCODE001 CUSTOMER NAME      N - REC ADDR 1 REC ADDR 2    WORLD  SENDER NAME - SEND ADDR 1 SEND ADDR 2 SEND ADDR 3 STATE POSTCODE   S CARRIER NAME 999123 BY ROAD N   -       6 18 0 0 0  N    10.00 11.00 0 11.00 11.00 0 11.00 11.00 1     N      N -     -     -ABCDEFGHIJ000000990001 -ABCDEFGHIJ000000990002 -ABCDEFGHIJ000000990003 -ABCDEFGHIJ000000990004 -ABCDEFGHIJ000000990005 -ABCDEFGHIJ000000990006 0 - T000123 CUSTOMER 6 6  -    -    -    -     
------------------------------------------------------------------------------------------------
I am importing the dat into temp table. and 1st script works fine.

CREATE TABLE dbo.[#tmp_xml_data](
[ref] [varchar](100),
[cdesc] [varchar](15),
[cno] [varchar](14),
[cdate] [varchar](10),
[cname] [varchar](50))

DECLARE @c xml
SELECT @c = BulkColumn FROM OPENROWSET(BULK &#039;C:\imports\sample.xml&#039;, SINGLE_BLOB) AS A

INSERT INTO [#tmp_xml_data]
SELECT Details.value(&#039;Ref[1]&#039;,&#039;VARCHAR(100)&#039;),
Details.value(&#039;Desc[1]&#039;,&#039;VARCHAR(15)&#039;),
T.C.value(&#039;ConNo[1]&#039;,&#039;VARCHAR(14)&#039;),
T.C.value(&#039;ConDate[1]&#039;,&#039;VARCHAR(10)&#039;),
T.C.value(&#039;CarrierName[1]&#039;,&#039;VARCHAR(50)&#039;)
FROM @c.nodes(&#039;MyImportFile/Connote&#039;) AS T(C)
CROSS APPLY @c.nodes(&#039;MyImportFile/Connote/RecAddr/FreightLineDetails&#039;) AS T2(Details)

This works fine and I get the data in to my temp table

however when I modify the script (see below) to get the data from more tags then it does not works. Could you please help.

CREATE TABLE dbo.[#tmp_xml_data](
[ref] [varchar](100),
[cdesc] [varchar](15),
[cno] [varchar](14),
[cdate] [varchar](10),
[add1] [varchar](50),
[add2] [varchar](50),
[add3] [varchar](50),
[cname] [varchar](50))

DECLARE @c xml
SELECT @c = BulkColumn FROM OPENROWSET(BULK &#039;C:\imports\sample.xml&#039;, SINGLE_BLOB) AS A

INSERT INTO [#tmp_xml_data]
SELECT Details.value(&#039;Ref[1]&#039;,&#039;VARCHAR(100)&#039;),
Details.value(&#039;Desc[1]&#039;,&#039;VARCHAR(15)&#039;),
T.C.value(&#039;ConNo[1]&#039;,&#039;VARCHAR(14)&#039;),
T.C.value(&#039;ConDate[1]&#039;,&#039;VARCHAR(10)&#039;),
T.C.value(&#039;Add1[1]&#039;,&#039;VARCHAR(50)&#039;),
T.C.value(&#039;Add2[1]&#039;,&#039;VARCHAR(50)&#039;),
T.C.value(&#039;Add3[1]&#039;,&#039;VARCHAR(50)&#039;),
T.C.value(&#039;CarrierName[1]&#039;,&#039;VARCHAR(50)&#039;)
FROM @c.nodes(&#039;MyImportFile/Connote&#039;) AS T(C)
CROSS APPLY @c.nodes(&#039;MyImportFile/Connote/RecAddr/FreightLineDetails&#039;) AS T2(Details)

----------------------------------------------------------------------------------------------

Could you please help.]]></description>
		<content:encoded><![CDATA[<p>Below is the sample xml file<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>- &#8211; 27/06/2011 123456789 7372 CCODE001 CUSTOMER NAME      N &#8211; REC ADDR 1 REC ADDR 2    WORLD  SENDER NAME &#8211; SEND ADDR 1 SEND ADDR 2 SEND ADDR 3 STATE POSTCODE   S CARRIER NAME 999123 BY ROAD N   &#8211;       6 18 0 0 0  N    10.00 11.00 0 11.00 11.00 0 11.00 11.00 1     N      N &#8211;     &#8211;     -ABCDEFGHIJ000000990001 -ABCDEFGHIJ000000990002 -ABCDEFGHIJ000000990003 -ABCDEFGHIJ000000990004 -ABCDEFGHIJ000000990005 -ABCDEFGHIJ000000990006 0 &#8211; T000123 CUSTOMER 6 6  &#8211;    &#8211;    &#8211;    &#8211;<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
I am importing the dat into temp table. and 1st script works fine.</p>
<p>CREATE TABLE dbo.[#tmp_xml_data](<br />
[ref] [varchar](100),<br />
[cdesc] [varchar](15),<br />
[cno] [varchar](14),<br />
[cdate] [varchar](10),<br />
[cname] [varchar](50))</p>
<p>DECLARE @c xml<br />
SELECT @c = BulkColumn FROM OPENROWSET(BULK &#8216;C:\imports\sample.xml&#8217;, SINGLE_BLOB) AS A</p>
<p>INSERT INTO [#tmp_xml_data]<br />
SELECT Details.value(&#8216;Ref[1]&#8216;,&#8217;VARCHAR(100)&#8217;),<br />
Details.value(&#8216;Desc[1]&#8216;,&#8217;VARCHAR(15)&#8217;),<br />
T.C.value(&#8216;ConNo[1]&#8216;,&#8217;VARCHAR(14)&#8217;),<br />
T.C.value(&#8216;ConDate[1]&#8216;,&#8217;VARCHAR(10)&#8217;),<br />
T.C.value(&#8216;CarrierName[1]&#8216;,&#8217;VARCHAR(50)&#8217;)<br />
FROM @c.nodes(&#8216;MyImportFile/Connote&#8217;) AS T(C)<br />
CROSS APPLY @c.nodes(&#8216;MyImportFile/Connote/RecAddr/FreightLineDetails&#8217;) AS T2(Details)</p>
<p>This works fine and I get the data in to my temp table</p>
<p>however when I modify the script (see below) to get the data from more tags then it does not works. Could you please help.</p>
<p>CREATE TABLE dbo.[#tmp_xml_data](<br />
[ref] [varchar](100),<br />
[cdesc] [varchar](15),<br />
[cno] [varchar](14),<br />
[cdate] [varchar](10),<br />
[add1] [varchar](50),<br />
[add2] [varchar](50),<br />
[add3] [varchar](50),<br />
[cname] [varchar](50))</p>
<p>DECLARE @c xml<br />
SELECT @c = BulkColumn FROM OPENROWSET(BULK &#8216;C:\imports\sample.xml&#8217;, SINGLE_BLOB) AS A</p>
<p>INSERT INTO [#tmp_xml_data]<br />
SELECT Details.value(&#8216;Ref[1]&#8216;,&#8217;VARCHAR(100)&#8217;),<br />
Details.value(&#8216;Desc[1]&#8216;,&#8217;VARCHAR(15)&#8217;),<br />
T.C.value(&#8216;ConNo[1]&#8216;,&#8217;VARCHAR(14)&#8217;),<br />
T.C.value(&#8216;ConDate[1]&#8216;,&#8217;VARCHAR(10)&#8217;),<br />
T.C.value(&#8216;Add1[1]&#8216;,&#8217;VARCHAR(50)&#8217;),<br />
T.C.value(&#8216;Add2[1]&#8216;,&#8217;VARCHAR(50)&#8217;),<br />
T.C.value(&#8216;Add3[1]&#8216;,&#8217;VARCHAR(50)&#8217;),<br />
T.C.value(&#8216;CarrierName[1]&#8216;,&#8217;VARCHAR(50)&#8217;)<br />
FROM @c.nodes(&#8216;MyImportFile/Connote&#8217;) AS T(C)<br />
CROSS APPLY @c.nodes(&#8216;MyImportFile/Connote/RecAddr/FreightLineDetails&#8217;) AS T2(Details)</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>Could you please help.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mahboob</title>
		<link>http://blog.sqlauthority.com/2009/02/13/sql-server-simple-example-of-reading-xml-file-using-t-sql/#comment-139963</link>
		<dc:creator><![CDATA[Mahboob]]></dc:creator>
		<pubDate>Thu, 09 Jun 2011 07:27:12 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2468#comment-139963</guid>
		<description><![CDATA[Thanks Pinal , really a nice solution, but i have an other issue that i have a large data and want to create its xml file but when i excutes above ur mentioned query i get the a small piece of results(approx 2k characters), please can you halp me out
Thanks]]></description>
		<content:encoded><![CDATA[<p>Thanks Pinal , really a nice solution, but i have an other issue that i have a large data and want to create its xml file but when i excutes above ur mentioned query i get the a small piece of results(approx 2k characters), please can you halp me out<br />
Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rahul</title>
		<link>http://blog.sqlauthority.com/2009/02/13/sql-server-simple-example-of-reading-xml-file-using-t-sql/#comment-136189</link>
		<dc:creator><![CDATA[rahul]]></dc:creator>
		<pubDate>Mon, 23 May 2011 10:26:50 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2468#comment-136189</guid>
		<description><![CDATA[
            
                
                    OSS_SERVERS
                    DLGGN01
                
                
                    
                        
                            vsDataMeContext
                            EricssonSpecificAttributes.10.22
                            
                                AEGIS2
                                10.155.63.92
                                vM.1.31
                                SYNCHRONISED
                                213
                                false
                            
                        
                    
                    
                        
                            
                            
                            Ericsson
                            AEGIS2
                            RBS
                            CXP9014346/1_R5AV/14
                            SubNetwork=ONRM_RootMo_R,ManagementNode=ONRM
                        
                        
                            
                                vsDataManagedElement
                                EricssonSpecificAttributes.10.22
                                
                                    SubNetwork=ONRM_RootMo_R,Site=RNC
                                    RBS3418
                                
                            
                        
                        ]]></description>
		<content:encoded><![CDATA[<p>OSS_SERVERS<br />
                    DLGGN01</p>
<p>                            vsDataMeContext<br />
                            EricssonSpecificAttributes.10.22</p>
<p>                                AEGIS2<br />
                                10.155.63.92<br />
                                vM.1.31<br />
                                SYNCHRONISED<br />
                                213<br />
                                false</p>
<p>                            Ericsson<br />
                            AEGIS2<br />
                            RBS<br />
                            CXP9014346/1_R5AV/14<br />
                            SubNetwork=ONRM_RootMo_R,ManagementNode=ONRM</p>
<p>                                vsDataManagedElement<br />
                                EricssonSpecificAttributes.10.22</p>
<p>                                    SubNetwork=ONRM_RootMo_R,Site=RNC<br />
                                    RBS3418</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rahul</title>
		<link>http://blog.sqlauthority.com/2009/02/13/sql-server-simple-example-of-reading-xml-file-using-t-sql/#comment-136188</link>
		<dc:creator><![CDATA[rahul]]></dc:creator>
		<pubDate>Mon, 23 May 2011 10:25:51 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2468#comment-136188</guid>
		<description><![CDATA[please can somebody tell me how to read this xml file in sql server..from the starting..i am a beginner..

i need the code urgently!




            
                
                    OSS_SERVERS
                    DLGGN01
                
                
                    
                        
                            vsDataMeContext
                            EricssonSpecificAttributes.10.22
                            
                                AEGIS2
                                10.155.63.92
                                vM.1.31
                                SYNCHRONISED
                                213
                                false
                            
                        
                    
                    
                        
                            
                            
                            Ericsson
                            AEGIS2
                            RBS
                            CXP9014346/1_R5AV/14
                            SubNetwork=ONRM_RootMo_R,ManagementNode=ONRM
                        
                        
                            
                                vsDataManagedElement
                                EricssonSpecificAttributes.10.22
                                
                                    SubNetwork=ONRM_RootMo_R,Site=RNC
                                    RBS3418
                                
                            
                        
                        ]]></description>
		<content:encoded><![CDATA[<p>please can somebody tell me how to read this xml file in sql server..from the starting..i am a beginner..</p>
<p>i need the code urgently!</p>
<p>                    OSS_SERVERS<br />
                    DLGGN01</p>
<p>                            vsDataMeContext<br />
                            EricssonSpecificAttributes.10.22</p>
<p>                                AEGIS2<br />
                                10.155.63.92<br />
                                vM.1.31<br />
                                SYNCHRONISED<br />
                                213<br />
                                false</p>
<p>                            Ericsson<br />
                            AEGIS2<br />
                            RBS<br />
                            CXP9014346/1_R5AV/14<br />
                            SubNetwork=ONRM_RootMo_R,ManagementNode=ONRM</p>
<p>                                vsDataManagedElement<br />
                                EricssonSpecificAttributes.10.22</p>
<p>                                    SubNetwork=ONRM_RootMo_R,Site=RNC<br />
                                    RBS3418</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sanjay</title>
		<link>http://blog.sqlauthority.com/2009/02/13/sql-server-simple-example-of-reading-xml-file-using-t-sql/#comment-136155</link>
		<dc:creator><![CDATA[Sanjay]]></dc:creator>
		<pubDate>Mon, 23 May 2011 05:27:35 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2468#comment-136155</guid>
		<description><![CDATA[Hello Sir,

My column datatype is nvarchar(MAX) and it stores  the value:
Closed

Could you please help me how I write the sql query to get only en-US value from the column?

Thanks in anticipation.

Ragards,
Sanjay]]></description>
		<content:encoded><![CDATA[<p>Hello Sir,</p>
<p>My column datatype is nvarchar(MAX) and it stores  the value:<br />
Closed</p>
<p>Could you please help me how I write the sql query to get only en-US value from the column?</p>
<p>Thanks in anticipation.</p>
<p>Ragards,<br />
Sanjay</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: srinivasan</title>
		<link>http://blog.sqlauthority.com/2009/02/13/sql-server-simple-example-of-reading-xml-file-using-t-sql/#comment-133045</link>
		<dc:creator><![CDATA[srinivasan]]></dc:creator>
		<pubDate>Thu, 05 May 2011 10:52:15 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2468#comment-133045</guid>
		<description><![CDATA[set @xml_ =&#039;false100504測試合同 ÓPCM üñ ¿¡&#039;]]></description>
		<content:encoded><![CDATA[<p>set @xml_ =&#8217;false100504測試合同 ÓPCM üñ ¿¡&#8217;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: srinivasan</title>
		<link>http://blog.sqlauthority.com/2009/02/13/sql-server-simple-example-of-reading-xml-file-using-t-sql/#comment-133044</link>
		<dc:creator><![CDATA[srinivasan]]></dc:creator>
		<pubDate>Thu, 05 May 2011 10:50:58 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2468#comment-133044</guid>
		<description><![CDATA[How to read a chinese text from XML in SQL server 2008

declare @xml_ xml 
set @xml_ =&#039;false100504測試合同 ÓPCM üñ ¿¡&#039;
		SELECT	
			OPCM_ALTERNATIVE_NAME = T.item.value(N&#039;(Name)[1]&#039;, &#039;NCHAR(100)&#039;)
		FROM @XML_.nodes(&#039;/Event/Body/Message&#039;) AS T(item)

i am getting value ???? ÓPCM ñ¿¡ instead of 測試合同 ÓPCM üñ ¿¡

Please help to find the solution]]></description>
		<content:encoded><![CDATA[<p>How to read a chinese text from XML in SQL server 2008</p>
<p>declare @xml_ xml<br />
set @xml_ =&#8217;false100504測試合同 ÓPCM üñ ¿¡&#8217;<br />
		SELECT<br />
			OPCM_ALTERNATIVE_NAME = T.item.value(N&#8217;(Name)[1]&#8216;, &#8216;NCHAR(100)&#8217;)<br />
		FROM @XML_.nodes(&#8216;/Event/Body/Message&#8217;) AS T(item)</p>
<p>i am getting value ???? ÓPCM ñ¿¡ instead of 測試合同 ÓPCM üñ ¿¡</p>
<p>Please help to find the solution</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mani</title>
		<link>http://blog.sqlauthority.com/2009/02/13/sql-server-simple-example-of-reading-xml-file-using-t-sql/#comment-130871</link>
		<dc:creator><![CDATA[Mani]]></dc:creator>
		<pubDate>Sun, 24 Apr 2011 14:47:18 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2468#comment-130871</guid>
		<description><![CDATA[-- SQL Server 2008 execution - xquery
DECLARE @xml xml = &#039; 
Host=ms0001xp/Pid=1400
mani
Thanigaimani 
&#039;
SELECT V.col.query(&#039;UserId&#039;).value(&#039;.&#039;, &#039;VARCHAR(32)&#039;) AS UserID,
       V.col.query(&#039;UserName&#039;).value(&#039;.&#039;, &#039;VARCHAR(32)&#039;) AS UserName
FROM @XML.nodes(&#039;StudyDeleteExtendedInfo&#039;) AS V(col);]]></description>
		<content:encoded><![CDATA[<p>&#8211; SQL Server 2008 execution &#8211; xquery<br />
DECLARE @xml xml = &#8216;<br />
Host=ms0001xp/Pid=1400<br />
mani<br />
Thanigaimani<br />
&#8216;<br />
SELECT V.col.query(&#8216;UserId&#8217;).value(&#8216;.&#8217;, &#8216;VARCHAR(32)&#8217;) AS UserID,<br />
       V.col.query(&#8216;UserName&#8217;).value(&#8216;.&#8217;, &#8216;VARCHAR(32)&#8217;) AS UserName<br />
FROM @XML.nodes(&#8216;StudyDeleteExtendedInfo&#8217;) AS V(col);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Manikandan S</title>
		<link>http://blog.sqlauthority.com/2009/02/13/sql-server-simple-example-of-reading-xml-file-using-t-sql/#comment-129145</link>
		<dc:creator><![CDATA[Manikandan S]]></dc:creator>
		<pubDate>Sat, 16 Apr 2011 05:59:01 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2468#comment-129145</guid>
		<description><![CDATA[Hi

Is there any way to call the API in sql server. (API returns XML data). if it is possible please suggest some sample.

Thanks
Manikandan]]></description>
		<content:encoded><![CDATA[<p>Hi</p>
<p>Is there any way to call the API in sql server. (API returns XML data). if it is possible please suggest some sample.</p>
<p>Thanks<br />
Manikandan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan Q</title>
		<link>http://blog.sqlauthority.com/2009/02/13/sql-server-simple-example-of-reading-xml-file-using-t-sql/#comment-126154</link>
		<dc:creator><![CDATA[Dan Q]]></dc:creator>
		<pubDate>Sat, 02 Apr 2011 00:41:10 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2468#comment-126154</guid>
		<description><![CDATA[Products &gt; Product &gt; SKU are the node levels.

Sorry forgot the xml would parse, here&#039;s another try at 
showing the original file:


  
    1
    Book
  
  
    2
    DVD
  
  
    3
    Video
  
]]></description>
		<content:encoded><![CDATA[<p>Products &gt; Product &gt; SKU are the node levels.</p>
<p>Sorry forgot the xml would parse, here&#8217;s another try at<br />
showing the original file:</p>
<p>    1<br />
    Book</p>
<p>    2<br />
    DVD</p>
<p>    3<br />
    Video</p>
]]></content:encoded>
	</item>
</channel>
</rss>

