Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Write permissions for a SP and the job agent

Author  Topic 

stephenbaer
Yak Posting Veteran

71 Posts

Posted - 2009-10-09 : 23:43:01
I have a procedure that uses EXEC xp_cmdshell several times. Unfortunately, SQL server can't write to a share with blocked inheritance. For instance,
EXEC xp_cmdshell 'del N:\MSSQL\Temp\GH_Utilization.xls', no_output works fine, since it exists as a subdirectory of MSSQL, but when attempting to copy or move files to a share,
Select @sql = 'exec xp_cmdshell ''move '+ @TempPath + @filename +
'N:\Shared Documents\Public Documents\GH Utilization Reports\'+ @filename + ''', No_Output'
EXEC (@sql)
, it doesn't work. There a lot of SQL<etc> users in the directory, but which one needs the write permission? This will be a job executed by the agent, by the way, but right now I'm just trying to execute straight from the editor. It can write to the root of C:, but not a share, which is just odd. I can only assume that it's the blocked inheritance on the folders in the share.

----------------
-Stephen

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-10-10 : 20:14:42
That's not how shares work. You use shares when you reference a UNC path: \\someServer\someShare.

If you want to refer to folders on a local drive, then either use the UNC path with the share or the local drive with the local folder.

It's the SQL Server service account that needs permission.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page
   

- Advertisement -