Solved

Problem with the folder given

Posted on 2013-01-10
11
335 Views
Last Modified: 2013-01-12
Hi,
This statement is working fine and also the image file goes to the table in its original format.
update dbo.user_master
set photo_file=(SELECT BulkColumn
FROM OPENROWSET(BULK N'C:\t93.jpg', SINGLE_BLOB) AS SRC)
where user_abbr='pc1';

But why do I get the problem for this, while "C:\setup\t93.jpg" is surely existing in the server with fine file format?
update dbo.user_master
set photo_file=(SELECT BulkColumn
FROM OPENROWSET(BULK N'C:\setup\t93.jpg', SINGLE_BLOB) AS SRC)
where user_abbr='pc1';

Msg 4861, Level 16, State 1, Line 2
Cannot bulk load because the file "C:\setup\t93.jpg" could not be opened. Operating system error code 5(Access is denied.).

How to ensure one DB user is able to upload whatever file within whatever folder of the server?
0
Comment
Question by:HuaMinChen
  • 5
  • 4
11 Comments
 
LVL 22

Accepted Solution

by:
Steve Wales earned 334 total points
ID: 38765939
You need to make sure that the user that is running the SQL Server service (not the user you connect to the database engine with) has access to the directory you're trying to read the file from.
0
 
LVL 10

Author Comment

by:HuaMinChen
ID: 38765992
How to make sure the DB user is able to access the folders of the machine? Thanks
0
 
LVL 22

Assisted Solution

by:Steve Wales
Steve Wales earned 334 total points
ID: 38766006
I'll have to defer to someone who knows Windows level security better than me, I'm afraid.

Check out the Security section of these two documents:

http://msdn.microsoft.com/en-us/library/ms188365.aspx
http://msdn.microsoft.com/en-us/library/ms175915.aspx

I believe that the section on "Security Account Delegation (Impersonation)" is particularly relevant.
0
 
LVL 10

Author Comment

by:HuaMinChen
ID: 38766031
No, there can be some control in Sql server on the DB user's privileges to access the folders of the current Windows server, can't there?
0
 
LVL 22

Expert Comment

by:Steve Wales
ID: 38766049
Nope - it's all about the SQL Server service owner account and the privileges it has.  Read those links from my earlier response.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 10

Author Comment

by:HuaMinChen
ID: 38766062
If you see the statements I've run above, one is with "c:\setup" which leads to the problem, one with "c:\" which is fine. This means the current DB user is having access to "c:\" while not to "c:\setup", as I am using the same DB user for doing the above. Then where is the control to make "c:\setup" "available/seeable" to the current DB user.
0
 
LVL 75

Assisted Solution

by:Anthony Perkins
Anthony Perkins earned 166 total points
ID: 38769234
This means the current DB user is having access to "c:\" while not to "c:\setup", as I am using the same DB user for doing the above.
No, it does not mean that.  As indicated previously, this has nothing to do with the database user and everything to do with the SQL Server service startup account.
0
 
LVL 10

Author Comment

by:HuaMinChen
ID: 38769408
I've requested that this question be deleted for the following reason:

I have not got one clear answer with satisfaction to this and this is no more needed. Thanks
0
 
LVL 22

Expert Comment

by:Steve Wales
ID: 38769409
The answers given were correct - the security on the SQL Server service owner account needs to be modified to have access to whatever directories are needed for the bulk insert.  Links to Microsoft KB articles were provided.  

The remaining unanswered portion is the "how" on the Windows Security side, but that is a Windows OS issue, not a Database issue so I believe the question was satisfactorily answered.
0
 
LVL 10

Author Comment

by:HuaMinChen
ID: 38770012
I've requested that this question be deleted for the following reason:

I said this is no more needed as there is no "fine" resolution given.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.

747 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

9 Experts available now in Live!

Get 1:1 Help Now