File Transer using SQL

  • Hi Everyone!

    Can you please help me here, I want to transfer pdf files from one server to the other using Sql, but the server I try to transfer from it needs username and password.  Here is my script and i get the error "Logon failure: unknown user name or bad password."

    Script

    exec master..xp_cmdshell 'copy \\Server1\Development\ZA\*.pdf  c:\files\

    Please help

     

  • Hi mmatseke

    Is the SQL Server service that you are running your SQL statement from running under a Domain account with rights to the \\Server1\Development\ZA\ directory on server 1 rather than a local account (which has no rights to other servers) ?

     

  • You need to grand sysadmin fix role to the account that you use to run xp_cmdshell procedure.


    Jie Ma

  • If you want various users to run this stored procedure, you may run into many security issues. If that is what you're trying to do, you may consider having the stored procedure called from a job and have a new stored procedure for launching the job. That way the users can start the job (which runs under the MS SQL SERVER AGENT service sign-on) rather than setting up security for all the users to the origination and destination folders.

  • 1.  Enable non-system administrators to execute the xp_cmdshell extended stored procedure in SQL Server 2000 as MS Article 890775

    2.  Create a group and Grand exec xp_cmdshell permission to the group and add user to that group.


    Jie Ma

  • xp_cmdshell 'net use \\server\share password /user:domain\user & copy \\server\share\* c:\wherever & net use \\server\share /d'

     

    not good practice, but if you need to do it once. it works fine.

Viewing 6 posts - 1 through 5 (of 5 total)

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