Wednesday, March 7, 2012

Error with Openrowset

I have a text file, that I need to import to SQL. I am trying to do this using OPENROWSET. This is the qry i use below.

select * from OpenRowset('MSDASQL',
'Driver={Microsoft Text Driver
(*.txt; *.csv)};
DefaultDir=c:\edge;',
'select * from
vwConstrLendingLoanDefiDetailReady.txt')

I have created a System DSN, For the microsoft text driver. Anyhow it throws this error:

Server: Msg 7399, Level 16, State 1, Line 1
OLE DB provider 'MSDASQL' reported an error.
[OLE/DB provider returned message: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified]
OLE DB error trace [OLE/DB Provider 'MSDASQL' IDBInitialize::Initialize returned 0x80004005: ].

Any idea why?

If this is in SQL 2005

Go to Surface Area Configuration->Surface Area Configuration for Features
Database Engine->Ad Hoc Remote Queries
Make sure 'Enable OPENROWSET and OPENDATASOURCE Support' is checked.|||It is SQL SERVER 2000. I have used Openrowset while connecting to other dbs like SQL Server etc...|||i FOUND THE Fix. I had an extra space, in mjy qry. Fixed that and it was able to execute the qry, and return the data.

No comments:

Post a Comment