[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Import CSV into Sql Server with OPENROWSET

Posted on 2010-08-16
1
Medium Priority
?
1,183 Views
Last Modified: 2012-05-10
I'm trying to import a simple .csv into Sql Server 8 with OPENROWSET:

Select * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=C:\IMPORTFILES\test.csv', 'SELECT * FROM [Sheet1$]')

I get the following error:

Server: Msg 7399, Level 16, State 1, Line 1
OLE DB provider 'Microsoft.Jet.OLEDB.4.0' reported an error. The provider did not give any information about the error.
OLE DB error trace [OLE/DB Provider 'Microsoft.Jet.OLEDB.4.0' IDBInitialize::Initialize returned 0x80004005:  The provider did not give any information about the error.].

I have verified the .csv file is valid and can be opened in Excel.  I've done this is the past without errors, can't see what's wrong this time.
0
Comment
Question by:kevbob650
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 7

Accepted Solution

by:
macentrap earned 2000 total points
ID: 33450580
You are using .csv wont you be using Microsoft Text Driver??


SELECT * FROM OPENROWSET('MSDASQL', 'Driver={Microsoft Text Driver (*.txt; *.csv)};DEFAULTDIR=C:\IMPORTFILES\;Extensions=CSV;','SELECT * FROM test.csv')

With Excel I have used please try to add IMEX=1

I have used this in SQL 2008
UPDATE SL1
SET
SL1.QTY = T1.QTY                  

FROM  

(select * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',

'Excel 8.0;DATABASE=D:\qty.xls;IMEX=1','Select * from [Results$]'))AS T1,

Stock SL1
WHERE
T1.Code COLLATE DATABASE_DEFAULT  = SL1.Code COLLATE DATABASE_DEFAULT
and T1.Loc  = SL1.Loc
0

Featured Post

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
I have a large data set and a SSIS package. How can I load this file in multi threading?
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question