Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Problem with the folder given

Posted on 2013-01-10
11
Medium Priority
?
390 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
[X]
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
  • 5
  • 4
11 Comments
 
LVL 23

Accepted Solution

by:
Steve Wales earned 1336 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 11

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 23

Assisted Solution

by:Steve Wales
Steve Wales earned 1336 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
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 
LVL 11

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 23

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
 
LVL 11

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 664 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 11

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 23

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 11

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

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

Question has a verified solution.

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

It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
What we learned in Webroot's webinar on multi-vector protection.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

722 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