Solved

bulk insert data file from a shared network drive

Posted on 2007-03-19
2
754 Views
Last Modified: 2012-05-05
Hi experts:

I haven't been able to resolve this problem for days now. It's kind of complicated but I am hoping I can describe the problem clear and one of you guys could help me dig out the root cause.

I have a stored procedure located in a SQL Server database running on a server, let's call it MYSQLSERVER that does something like:
bulk insert #mytable from ‘\\MYFILESERVER\data\myfile.csv’
with…

The "data" folder of MYFILESERVER is a shared network drive that I and everyone in the office has read/write/exeute access right to it.

The stored procedure works fine if I execute it from MYSQLSERVER through Management Studio but gives me error message if:
1. I execute it from my desktop either through Management Studio or through a VBA program located on the ''MYFILESERVER\data" network drive. The error message:
"Cannot bulk load because the file "\\MYFILESERVER\data\myfile.csv" could not be opened. Operating system error code 5(Access is denied.)."
2. if I execute it from MYSQLSERVER through the VBA program located on MYFILESERVER/data. Error message is thrown at the code trying to access to resulting recordset:
"Operation is not allowed when the object is closed."

I use a domain account to log in my desktop. I am also able  to log on to MYSQLSERVER using the same account. I have no problem read/write a file on the shared network drive on MYFILESERVER either from my desktop or from MYSQLSERVER using this same account.

Please help.  Thank you.


 

0
Comment
Question by:sdc248
2 Comments
 
LVL 21

Accepted Solution

by:
ziolko earned 250 total points
ID: 18749276
make sure that user that starts SQL server has access rights to folder/file

ziolko.
0
 
LVL 16

Assisted Solution

by:rboyd56
rboyd56 earned 250 total points
ID: 18749486
Sounds like you are connecting to SQL Server with NT authentication.

If this is the case, BULK INSERT does not support delegation unless everything is configured correctly. The first problem is caused by delegation. In order to make this work, the SQL Server service account has to be trusted for delegation in Active Directory. The account that is running the BULK INSERT command also has to be trusted for delegation.

This is documented in Books on Line under BULK INSERT.

You can switch to SQL authentication and it will probably work as long as the SQL Server service account has access to the folder and file.

As far at the second problem goes, that sounds like more of a VB problem that I do not know how to address. It appears the connection object got closed prematurely.
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
2016 SQL Licensing 7 41
How to create a unique rule restriction on a table for two fields 16 82
Passing Parameter to Stored Procedure 4 24
SQL Query assistance 16 25
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

773 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