SQL Server Performance

Usage of XP_CMDSHELL with Network drive.

Discussion in 'General DBA Questions' started by Raghu, Jan 10, 2008.

  1. Raghu New Member

    I have a share drive mapped as F to one of the servers using a specific login account.

    I am able to access the mapped drive in command prompt using "Dir F:"
    I am not able to access the mapped drive through SQL server using XP_CMDSHELL (xp_cmdshell 'Dir F:')
    SQL server doesn't have access to the share drive. I can't provided access to my SQL server, since the share drive in different domain.
    Do we have any option to access the mapped drive or network drive using login information with xp_cmdshell in SQL server.
    My purpose is to copy files between the two server through SQL server. Is there any Copy command available to use with login information

    Thanks
    Raghu
  2. satya Moderator

    Ensure the SQL Server service account has relevant privileges on that network share, then you can easily copy the backup file using TSQL - XP_CMDSHELL Statement in this cas.
  3. Raghu New Member

    Yes, you are right.
    Since the SQL servers are in two different domain i can grant permission to the service account, also i am connecting the other SQL server through SQL authentication.
    is it possible to provide access to SQL users?
    so i am looking for few copy command where we can use the login information to copy the file.
  4. satya Moderator

    If no trust between domains, then simply create same account such 'sqladmin' on both domains with necessary privileges and perform the task from sql.
  5. Raghu New Member

    Yes, by creating the SQL user i am able to access the SQL server from both the servers, but i am not able to access files from OS.
    Is it possible to grant access to SQL user on local administrator group on both the servers.
  6. satya Moderator

    I should be more clear, create a domain based account with same name and perform the activity and unless the SQL Server service account has relelvant permission its hard to access the network share as it works with that account when going out of SQL.

Share This Page