[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

bulk insert data file from a shared network drive

Posted on 2007-03-19
2
Medium Priority
?
793 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 750 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 750 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how the fundamental information of how to create a table.
Suggested Courses

873 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