Creating Remote folder using XP_CMDSHELL in SQL 2005

  • I have a code to create remote folder in SQL 2000. It is not working in SQL 2005. I have enabled the xp_cmdshell option in 2005 and working fine creating local folder.

    the command is as follows

    EXEC MASTER..XP_CMDSHELL 'MD "\\server1\Reports\files\06 Aug 2008"'

    Its return error as Access denied. The shared folder has necessary permissions to created folders.

  • Are you sure that you have given permission to SQL Server Service Account to create the directory? (check the service itself and see what log on it is using.)

    The best explanation of all this seems to be on

    http://sqlblog.com/blogs/tibor_karaszi/archive/2007/08/23/xp-cmdshell-and-permissions.aspx

    There are subtle differences between SQL Server 2000 and 2005 as you'll see.

    Best wishes,
    Phil Factor

  • Thanks for your reply. I have checked the shared path. That machine not in the same domain as source

    Is it possible to create folder in remote machine which is not in the same domain??

  • You could create a cross-domain trust relationship which would allow the logon the agent is using in your domain to have privileges in the target domain. This would typically be setup by the domain administrator of the target domain.


    Have Fun!
    Ronzo

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

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