Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

bulk insert data file from a shared network drive

Posted on 2007-03-19
2
757 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

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 extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

792 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