473,382 Members | 1,743 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Using OPENROWSET to import a textfile

38
Help please, im trying to use open OPENROWSET to import a csv file into my database
Here is the code im using


Expand|Select|Wrap|Line Numbers
  1.  
  2. --Read CSV using OpenRowSet
  3. select * from OpenRowset('MSDASQL', 'Driver={Microsoft Text Driver (*.txt; *.csv)};
  4.   DefaultDir=D:\MSSQL\Data\FUELBCP\;','select top 6 * from
  5. TRANS.csv')
  6.  
  7.  
and i get this error

OLE DB error trace [OLE/DB Provider 'MSDASQL' IColumnsInfo::GetColumnsInfo returned 0x80004005: The provider did not give any information about the error.].
Msg 7399, Level 16, State 1, Line 1
OLE DB provider 'MSDASQL' reported an error. The provider did not give any information about the error.


I am using OPENROWSET because i can the compare the text file to a table and the update the table base on what is in the text file but not in the table

If anyone knows why i am getting this error please put me out of my misery and help me out

Thanks
Mar 29 '07 #1
2 21118
iburyak
1,017 Expert 512MB
I am not in a position to solve your problem but try to select not * but one column, then add one column at a time. It looks like top row that has column headers have invalid character or maybe just extra space or tab between columns which is enough to make server confused.

Good Luck.
Mar 29 '07 #2
tezza98
38
I found the soultion and here it is
It works perfectly

Expand|Select|Wrap|Line Numbers
  1.  
  2. OPENROWSET('Microsoft.Jet.OLEDB.4.0',
  3. 'Text;Database=\\w2ks1\MSSQL\DATA\FUELBCP',
  4. 'select  * from TRANS.csv') 
  5.  
  6.  
Mar 29 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: John Taylor | last post by:
I have a class that has this code in it: def __init__(self,Site): self.Site = Site import_cmd = "from regexpr_%d import *" % ( int(self.Site.id) ) exec( import_cmd ) print AGENT # fails,...
1
by: billmiami2 | last post by:
I'm trying to pass through a SQL statement to an Oracle database using OPENROWSET. My problem is that I'm not sure of the exact syntax I need to use when the SQL statement itself contains single...
1
by: mark | last post by:
In Access 2000 and 2002, I have created an import specification to import the fixed-width recordset below into an existing table. I am having strange problems with the import of the date and time...
2
by: VMI | last post by:
In Access, when a user's going to import a fixed-width format ascii file, a window in the "Import Text Wizard" lets the user "mark" where in a string one field will begin and end (with the vertical...
2
by: randar | last post by:
I'm having problems getting an XML document to validate against a fairly complex scenario. Goals: -To have two schemas with two different namespaces, so that I can validate each one seperately...
1
by: saidireddy | last post by:
what's the difference between import key word in vb.net and using key word in c# don't say these are same because if it is same why .net frame work allowing two key words instead of one key word
0
by: rradhak | last post by:
Hi, We use udb version 8.1 fixpack 11 under AIX 5.3 Is there a way to use load/import against temporary tables? DB2 does not recognize session tables. Is there any workaround?
5
by: kashif73 | last post by:
I have a text file with hundreds of records. each line contain 1250 values seperated by a semicolon. I have created 2 tables in SQL server 2000, one with 1000 columns & the second with 250 columns....
1
by: kallem | last post by:
Hi, I am executing following query and i am getting following error Msg 8152, Level 16, State 10 String or binary data would be truncated.
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.