0

How can I copy file from 1 server computer to another using xp_cmdshell with credentials.I have an application server and database server.I want to transfer a file from data server to application server by executing the xp_cmdshell command by using the network credentials of the application server. Iam using sql server 2012 and I have configured xp_cmdshell in the SQL Server.

I got "Access is denied" error when I tried to transfer file from my local computer to a specific folder in my shared network.

Please help me...

neer
  • 4,031
  • 6
  • 20
  • 34

1 Answers1

0

It's a guess of course.

From this MSDN article you can find that

The Windows process spawned by xp_cmdshell has the same security rights as the SQL Server service account

that means that this windows service account should have rights to the shared folder - which is not true I believe in your case.

So, to fix this you can specify a xp_cmdshell Proxy Account and then xp_cmdshell will execute commands under this specified account

Example:

EXEC sp_xp_cmdshell_proxy_account 'SHIPPING\KobeR','sdfh%dkc93vcMt0';
Andrey Morozov
  • 7,839
  • 5
  • 53
  • 75