Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

BULK INSERT failing. Expand / Collapse
Author
Message
Posted Friday, February 3, 2012 3:45 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, September 16, 2014 9:41 AM
Points: 13, Visits: 111
Hello,

I have a situation where I am trying to do a bulk insert of a file that's on a network share. It's failing with:

Cannot bulk load because the file "\\Server\Folder\File" could not be opened. Operating system error code 5 (failed to retrieve text for this error. Reason: 15105).

What I think is odd though is that use of xp_FileExist confirms that that the file exists and the SQL Server can see it.

The remote folder has permissions for "Everyone". Is there an internal setting in SQL Server that has been set to prevent me doing this? It's a new server and so this has never been done before. But it worked fine in pre-production, on a different server.

Hope you can help.

J




Post #1246339
Posted Friday, February 3, 2012 3:53 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: 2 days ago @ 5:46 AM
Points: 2,443, Visits: 7,557
Jamie Ashton (2/3/2012)
Hello,

I have a situation where I am trying to do a bulk insert of a file that's on a network share. It's failing with:

Cannot bulk load because the file "\\Server\Folder\File" could not be opened. Operating system error code 5 (failed to retrieve text for this error. Reason: 15105).

What I think is odd though is that use of xp_FileExist confirms that that the file exists and the SQL Server can see it.

The remote folder has permissions for "Everyone". Is there an internal setting in SQL Server that has been set to prevent me doing this? It's a new server and so this has never been done before. But it worked fine in pre-production, on a different server.

Hope you can help.

J


Error code 5 is permissions, so it might be worth checking that whatever account your SQL Server runs under has permission. Check the account used by the pre-production server and see if it's using the same.



Not a DBA, just trying to learn

For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/

For better, quicker answers on SQL Server performance related questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/



If you litter your database queries with nolock query hints, are you aware of the side effects?
Try reading a few of these links...

(*) Missing rows with nolock
(*) Allocation order scans with nolock
(*) Consistency issues with nolock
(*) Transient Corruption Errors in SQL Server error log caused by nolock
(*) Dirty reads, read errors, reading rows twice and missing rows with nolock


LinkedIn | Blog coming soon (for sufficiently large values of "soon" )!
Post #1246345
Posted Friday, February 3, 2012 3:54 AM


SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Thursday, August 22, 2013 9:13 AM
Points: 496, Visits: 601
Hi Jamie

I faced a similar situation not too long ago trying to do the exact same thing. I don't have a verifiable link but from experience, I've found SQL Server in general and SSIS packages in particular DO NOT get on with network shares at all.

You'll need to put the input file on a local drive for this to work. Don't forget about your BULK INSERT options, too - make sure they're set for the type of file you're using.



---

Note to developers:
CAST(SUBSTRING(CAST(FLOOR(NULLIF(ISNULL(COALESCE(1,NULL),NULL),NULL)) AS CHAR(1)),1,1) AS INT) == 1
So why complicate your code AND MAKE MY JOB HARDER??!

Want to get the best help? Click here http://www.sqlservercentral.com/articles/Best+Practices/61537/ (Jeff Moden)
My blog: http://uksqldba.blogspot.com
Visit http://www.DerekColley.co.uk to find out more about me.
Post #1246346
Posted Friday, February 3, 2012 3:57 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, September 16, 2014 9:41 AM
Points: 13, Visits: 111
Thanks both for your speedy answers!

Firstly the permissions... surely "Everyone" would encompass the SQL Server account?

And yes - I'd love to have the file locally - but it's impossible in this situation.

Don't you think it's odd that XP_FileExist can see it yet BULK INSERT fails?

Or are separate accounts involved?

J
Post #1246350
Posted Friday, February 3, 2012 4:03 AM


SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Thursday, August 22, 2013 9:13 AM
Points: 496, Visits: 601
I think it's got to be something to do with accounts. Maybe grant the SQL Server accounts explicit permissions on the network share. In terms of the XP call working, I suspect that internally it's using something like the Windows COM objects or some other Windows API which is returning a result (as it would do if you e.g. browsed a normal window).

A quick bit of Googling has found this which might be of help:


1) The SQL Server services, on the Server containing the instance of SQL Server, must be running under a domain-level account (e.g. A Domain Administrator account). This is accomplished by changing the "Log On" properties for the services named "MSSQLSERVER" and "SQLSERVERAGENT" on the server running SQL Server (not your local instance). When you have completed changing the log on information for these 2 services, you will need to restart the "MSSQLSERVER" service on that server. Note that this will ask if you want to restart the "SQLSERVERAGENT" as well - Answer: Yes.

2) The SQL Server service account must have FULL CONTROL rights to the file system folder and to the share. That means you need to have a shared location in which the logon account you specified in 1 (above) has full control rights.

3) The file share should only be accessed via UNC name. Mapped drives may not be consistently visible to the SQL Service.

4) You cannot specify the path by using the browse ellipses (...). You must type the fully qualified path into the text box as:

file://ComputerName/ShareDirectoryWithRightsForDomain-levelAccountUsed/NameofFile.Extension



Additional Notes:
When creating or restoring backups on a network share, a significant increase in network traffic may result. You should ensure that your network can handle this without causing poor performance for other systems or end users. It may also benefit you to establish a dedicated physical network connection between your database server and your backup file host. Once the SQL Server instance is configured, you can use your local Enterprise Manager to create or restore a database backup that resides on a network device other than the device your instance of SQL Server is running on.



(from http://www.fmsinc.com/free/NewTips/SQL/SQLtip9.asp)

I know this relates to SQL Server 2000 but I suspect it's right.


---

Note to developers:
CAST(SUBSTRING(CAST(FLOOR(NULLIF(ISNULL(COALESCE(1,NULL),NULL),NULL)) AS CHAR(1)),1,1) AS INT) == 1
So why complicate your code AND MAKE MY JOB HARDER??!

Want to get the best help? Click here http://www.sqlservercentral.com/articles/Best+Practices/61537/ (Jeff Moden)
My blog: http://uksqldba.blogspot.com
Visit http://www.DerekColley.co.uk to find out more about me.
Post #1246355
Posted Monday, February 6, 2012 2:19 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, September 16, 2014 9:41 AM
Points: 13, Visits: 111
Thanks all for your help on this one.

My research indicates numerous possible causes, but in this instance, it looks to be a permissions issue going across domains.

J
Post #1247136
Posted Monday, January 14, 2013 9:15 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Thursday, February 7, 2013 11:21 PM
Points: 34, Visits: 60
I just solved this issue.

two ways,

1, remote desktop to sql server do bulk insert there.

2, or you can use sql authentication to login.

have fun
Post #1407013
Posted Thursday, May 23, 2013 4:04 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Yesterday @ 2:32 AM
Points: 31, Visits: 328
Bump!

Just thought I'd add my two-penneth as I was getting this exact error today and this was the first post I found on a search.

The BULK INSERT is performed from a stored procedure, specifically looking for a file in a local path. My problem wasn't permissions, some f**kwit decided it was a good idea to rename the folder!
Post #1455921
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse