Tell me more ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I am try to run bulk insert command on SQL Server 2008 but I am having issues with the security. after researching via internet, the problem has something to do with account delegation and impersonation.

However all solutions seems to point to an Active Directory setup which my setup is not.

My setup is SQL Server 2008 Express on Windows Server 2008 Standard configured as a workgroup.

Despite a SQL Server user account, assigned all the user mappings and server roles and ensuring security set to SQL, I am getting this error:

Msg 4861, Level 16, State 1, Line 1
Cannot bulk load because the file "\server_name\file_name.txt" could not be opened. Operating system error code 5 (Access is denied.).

So, how does one setup SQL Server account delegation and impersonation on a workgroup environment?

Thanks in advance

share|improve this question
1  
Can you show us your code? How are you trying to load this file? Does the machine where SQL Server 2008 lives have access to that UNC path?? The Access denied error typically happens if you (or more precisely: the account running SQL Server) doesn't have access to that path – marc_s Dec 28 '12 at 7:25
you could add the local admin as a service account instead of "Network Service".. – Rohan Dec 28 '12 at 11:27

migrated from stackoverflow.com Dec 28 '12 at 9:12

3 Answers

the error means that your os denied access to the file, you can try running your code after running ssms as administrator, or you can login to ssms using win authentication with the computers admin user.

share|improve this answer

the following is my code:

If object_id('tempdb..#POSSales') is not null DROP TABLE #POSSales;
CREATE TABLE #POSSales (InvoiceNumber varChar(11) COLLATE database_default, SalesDate varchar(11), CustomerNumber varchar(20), ItemNumber varchar(30), Qty real, [Description] varcHar(255),
ExTaxPrice Money Default 0 Not Null, IncTaxPrice Money Default 0 Not Null, TaxCode Varchar(3), Inclusive Varchar(1), Location Varchar(10), ExportDate VarcHar(11),
TotalInvAmt Money Default 0 Not Null  );

BULK INSERT #POSSales FROM 'E:\epoint\MYOB\V1K10121349_SLS.txt' WITH (FIRSTROW = 1);

The line at "BULK INSERT..." is causing the error. It runs fine if i am at there server.

regards rashid.

share|improve this answer
1  
This shouldn't have been posted as an answer. Please remove this and put this information as an edit to your question. – Thomas Stringer Dec 29 '12 at 4:28
All you need to do is sign in over here with the same method you use on SO and we can help from there. – Jack Douglas Dec 29 '12 at 4:44

Based on the information you provided in the SQL script, the NT account which the SQL Server service is running under doesn't have access to the folder which the file is sitting in. You'll need to see which account the SQL Service is running under, then grant that account rights to the folder.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.