Solved

bulk insert data file from a shared network drive

Posted on 2007-03-19
2
740 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
Comment Utility
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
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

763 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now