Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 OPENROWSET Problem

Author  Topic 

DeveloperIQ
Yak Posting Veteran

71 Posts

Posted - 2009-02-15 : 19:02:39
I have a CSV file which does not have column headers. I am using in SQL 2005 to do a select from this file.

SELECT * FROM
OPENROWSET ('MSDASQL', 'Driver={Microsoft Text Driver (*.txt; *.csv)};DBQ=C:\TestFolder;', 'SELECT * from Test.csv')

The error I get is

Duplicate column names are not allowed in result sets obtained through OPENQUERY and OPENROWSET. The column name "NoName" is a duplicate.

What is wrong with this. How else can I extract data from this file

mfemenel
Professor Frink

1421 Posts

Posted - 2009-02-15 : 19:37:56
Try the jet provider instead with HDR=NO. change the folder back to your setup.

SELECT *
FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Text;Database=C:\;HDR=NO',
'SELECT * FROM test.csv')

Mike
"oh, that monkey is going to pay"
Go to Top of Page

DeveloperIQ
Yak Posting Veteran

71 Posts

Posted - 2009-02-15 : 19:56:22
That worked like a charm. Thank You!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-15 : 21:07:51
the original error message seems like you had more than one column with header NoName
Go to Top of Page
   

- Advertisement -