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
 General SQL Server Forums
 New to SQL Server Programming
 Import CSV file in Data Table using OpenRowSet

Author  Topic 

rekakannan
Starting Member

4 Posts

Posted - 2011-02-25 : 08:43:59
select
A.[Name],
A.SurName,
--A.Phone,
Substring(A.Phone,1,len(A.Phone)-1) as Phone,
--A.Policyno,
Substring(A.Policyno,1,len(A.Policyno)-1) as Policyno,
--A.CustomerID,
A.Channel,
A.CityPreCode,
A.Gender,
Getdate()
--select distinct A.phone
from
(
select * from OpenRowset('MSDASQL',
'Driver={Microsoft Text Driver (*.txt; *.csv)};DefaultDir=C:\;',
'select * from nilLive2.csv')
) A


Im trying to select the csv file data from a specified path. But it shows the following error.



OLE DB provider "MSDASQL" for linked server "(null)" returned message "[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified".
Msg 7303, Level 16, State 1, Line 1
Cannot initialize the data source object of OLE DB provider "MSDASQL" for linked server "(null)".

Please any one help me.

MIK_2008
Master Smack Fu Yak Hacker

1054 Posts

Posted - 2011-02-25 : 14:00:15
Make sure the file exists on the specified location exactly with the same name and have full permission to the user/account through which you are logged into the SQL server . Also make sure that the file is not opened at the time while you are executing the above query ..



Cheers
MIK
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-02-26 : 09:14:08
is path local computer path or server path?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

rekakannan
Starting Member

4 Posts

Posted - 2011-02-28 : 00:50:24
quote:
Originally posted by MIK_2008

Make sure the file exists on the specified location exactly with the same name and have full permission to the user/account through which you are logged into the SQL server . Also make sure that the file is not opened at the time while you are executing the above query ..



Cheers
MIK



Im sure that i kept the file in a specified location and closed the file while running the query. But still showing the same error.

Any Idea?

-Rekha Kannan


Go to Top of Page

rekakannan
Starting Member

4 Posts

Posted - 2011-02-28 : 00:51:57
quote:
Originally posted by visakh16

is path local computer path or server path?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/





I kept the file in a server path only.
Go to Top of Page

rekakannan
Starting Member

4 Posts

Posted - 2011-02-28 : 00:52:56
quote:
Originally posted by visakh16

is path local computer path or server path?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/





I kept the file in a server path only.
-Rekha Kannan
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-03-03 : 09:27:50
What happens when you try bulk insert?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -