XCOPY utility to Copy Files from One Server to Another!

  • exec master.dbo.xp_cmdshell N'Xcopy D:\partbackup \\XXX.YY.ZZZ.44\D$\bkp /i'

    I am using the above script in my SQL Job (one of the steps in the job) to copy files across servers.

    During this process, I want to retain one 'OUTPUT' file where all the performed details would be captured.

    Could you please let me know the appropriate 'switch' to be used and the syntax to fulfil my requirement?

    Thank you so much .. !!

    Thanks.

  • don't use xp_cmdshell from within a sqlagent job !

    SQLagent jobs can have job steps that execute dos commands.

    Create a doscmd jobstep and provide the needed windows auth for the sqlagent service account or the proxy account used in that job step.

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

  • Thanks for the suggestion..!!

    However, what would be the additional 'switch' to be used to create an OUTPUT file?

    Thanks.

  • Sourav-657741 (12/21/2010)


    Thanks for the suggestion..!!

    However, what would be the additional 'switch' to be used to create an OUTPUT file?

    For most DOS commands, a single greater-than sign followed by a filename (with path if necessary) at the end of the command will pipe the output to a specified file, overwriting it. A double greater-than sign will append the output to an existing file (making it if it doesn't exist).

    Does this answer what you're looking for?

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2

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

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