Access denied while copying a file through xp_cmdshell

  • Hi,
    I am using the following statement to copy file from my local system to remote system.
    the output i am getting is "Access Denied".  What could be the reason & what i have to do to solve this problem ?
    USE masterEXEC xp_cmdshell 'copy c:\sqldumps\pubs.dmp \\server2\backups\sqldumps'
    Regards,
    Bobby 
  • I ran into this problem a couple weeks ago.  Found that if I gave the SQL machine (not a user) access to the folder on the network with all privs EXCEPT FULL CONTROL, then the SQL Server SYSTEM account could take care of business.


    Butch

  • I too have had this problem when trying to export data from SQL Server to a text file on our network.

    The problem occurs because when you run commands through xp_cmdshell, the commands are not run under your security context.

    If you are a member of the sysadmin fixed server role and run xp_cmdshell, any commands you run are executed by the account under which MSSQL is running.

    If you are not a member of the sysadmin fixed server role and running either Windows NT or Windows 2000, any commands run as run by the user that is set as the  SQL Server Agent proxy account.  (This can be determed using xp_sqlagent_proxy_account)

    For Windows XP/2003, any commands you run are executed by the account under which MSSQL is running.

    I have found by making sure that both scenario's have appropriate access, I avoid this problem. 

    Hope this helps.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply