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.
| Author |
Topic |
|
lappin
Posting Yak Master
182 Posts |
Posted - 2011-08-24 : 11:36:22
|
| I need to import from a csv file with a flexible number of columns (depends on number of days in month) and the file has no column headers.I have initially triedSELECT *FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0','Text;Database=C:\;HDR=NO','SELECT * FROM myfile.csv]') but got the 64bit error "..single-threaded apartment mode..."So now replaced jet above with 'Microsoft.ACE.OLEDB.12.0'but now getting error:Edit: here is full message:"Duplicate column names are not allowed in result sets obtained through OPENQUERY and OPENROWSET. The column name "myfile#csv.NoName" is a duplicate."noName" error."My aim is to import csv file to a temp table then to pivot it so each day's data is put into a single column on a new row. But can't do this until I import csv file first. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-08-24 : 12:12:13
|
| seems like you've multiple columns with same name inside csv------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
lappin
Posting Yak Master
182 Posts |
Posted - 2011-08-25 : 05:01:34
|
| Yes I have multiple (all) columns with no name. Is there a way to import the data anyway. The format of the data is [ID1],0,1,0,0,1,....etc with each digit after ID field being a value for a day of a month. If I can import it I will pivot it to:ID,DateField[ID1],0[ID1],1[ID1],0...etc |
 |
|
|
lappin
Posting Yak Master
182 Posts |
Posted - 2011-08-25 : 05:26:28
|
| found a work around:http://stackoverflow.com/questions/2601941/bulk-insert-with-inconsistent-number-of-columns |
 |
|
|
|
|
|
|
|