<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   >
<channel>
    
    <title>Arogl Darthu's Blog - SQL</title>
    <link>http://blog.arogldarthu.nl/</link>
    <description>profound astoundment</description>
    <dc:language>en</dc:language>
    <generator>Serendipity 1.5.4 - http://www.s9y.org/</generator>
    <pubDate>Fri, 15 Apr 2011 09:11:32 GMT</pubDate>

    <image>
        <url>http://blog.arogldarthu.nl/templates/default/img/s9y_banner_small.png</url>
        <title>RSS: Arogl Darthu's Blog - SQL - profound astoundment</title>
        <link>http://blog.arogldarthu.nl/</link>
        <width>100</width>
        <height>21</height>
    </image>

<item>
    <title>T-SQL: Import csv in temp table</title>
    <link>http://blog.arogldarthu.nl/archives/13-T-SQL-Import-csv-in-temp-table.html</link>
            <category>SQL</category>
    
    <comments>http://blog.arogldarthu.nl/archives/13-T-SQL-Import-csv-in-temp-table.html#comments</comments>
    <wfw:comment>http://blog.arogldarthu.nl/wfwcomment.php?cid=13</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://blog.arogldarthu.nl/rss.php?version=2.0&amp;type=comments&amp;cid=13</wfw:commentRss>
    

    <author>nospam@example.com (Twan Jacobs)</author>
    <content:encoded>
    Seems pretty simple to do... Just execute a query like this one:&lt;br /&gt;
&lt;div style=&quot;font-family: Courier New&quot;&gt;&lt;div class=&quot;tsql geshi&quot; style=&quot;text-align: left&quot;&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;SELECT&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;*&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;INTO&lt;/span&gt; #TESTCSV&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;FROM&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;OPENROWSET&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;Microsoft.Jet.OLEDB.4.0&#039;&lt;/span&gt;,&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;Text;Database=C:&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\;&lt;/span&gt;HDR=YES&#039;&lt;/span&gt;,&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;SELECT * FROM test.csv&#039;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;/div&gt;&lt;/div&gt;In my case I was getting the following error message, which got me baffled for quite some time:&lt;br /&gt;
&lt;div style=&quot;font-family: Courier New; color: red&quot;&gt;Msg 492, Level 16, State 1, Line 1&lt;br /&gt;
Duplicate column names are not allowed in result sets obtained through OPENQUERY and OPENROWSET. The column name &quot;test#csv.NoName&quot; is a duplicate.&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
This really didn&#039;t make any sense to me. There were no duplicate column names in the csv file and surely there were no columns named &#039;NoName&#039;, nor did I forget to name a column...&lt;br /&gt;
&lt;br /&gt;
Then it came to me: what if &lt;strong&gt;UNICODE&lt;/strong&gt; isn&#039;t parsed correctly? Maybe that could cause empty columns headers? The file was exported by ReportViewer and I had not looked at the encoding of the resulting csv file. Guess what!? The encoding was UNICODE. So, after saving the file in &lt;strong&gt;ANSI&lt;/strong&gt; encoding, the query executed like a charm. 
    </content:encoded>

    <pubDate>Wed, 13 Apr 2011 09:55:34 +0000</pubDate>
    <guid isPermaLink="false">http://blog.arogldarthu.nl/archives/13-guid.html</guid>
    
</item>

</channel>
</rss>
