Running xp_cmdshell

  • Hi

    I need to copy some txt files from sql server to another server.

    Thought that would be easy but no....

    Using xp_cmdshell for this

    USE master;

    EXEC xp_cmdshell 'copy C:\CSVFILES\customerroutes.txt

    \\common\customerimport, NO_OUTPUT';

    It report success, but when I look in \\common\customerimport I see no file.

    Any one know why?

    Dan

  • remove the nooutput so you can see what's going on.

    You could also run that from the real cmd line so you get the real error message (if there's one)

  • Hi

    Tried without the no output. But no error meassge.

    Also I started command promt and typed it in as plain command

    That works just fine.

    Dan

  • Try doing a dir in both folders. That should show you access denied error.

  • Don't you need a destination file name (not just a folder) to make that command work correctly?

    Does SQL have permissions to write to that destination?

    Brandie Tarvin, MCITP Database AdministratorLiveJournal Blog: http://brandietarvin.livejournal.com/[/url]On LinkedIn!, Google+, and Twitter.Freelance Writer: ShadowrunLatchkeys: Nevermore, Latchkeys: The Bootleg War, and Latchkeys: Roscoes in the Night are now available on Nook and Kindle.

  • Thanks Brandie, that solved my issue. 🙂

    Dan

  • I've delete that job but I swear I've already done something similar to this :

    MOVE c:\backups\*.bak D:\backups[\].

    I'm 99.9% sure that you don't need a destination name for the file.

  • Dan-Ketil Jakobsen (6/23/2011)


    Thanks Brandie, that solved my issue. 🙂

    Which question solved your issue? I'm curious.

    Brandie Tarvin, MCITP Database AdministratorLiveJournal Blog: http://brandietarvin.livejournal.com/[/url]On LinkedIn!, Google+, and Twitter.Freelance Writer: ShadowrunLatchkeys: Nevermore, Latchkeys: The Bootleg War, and Latchkeys: Roscoes in the Night are now available on Nook and Kindle.

  • Ninja's_RGR'us (6/23/2011)


    I've delete that job but I swear I've already done something similar to this :

    MOVE c:\backups\*.bak D:\backups[\].

    I'm 99.9% sure that you don't need a destination name for the file.

    MOVE isn't the same as COPY necessarily.

    Brandie Tarvin, MCITP Database AdministratorLiveJournal Blog: http://brandietarvin.livejournal.com/[/url]On LinkedIn!, Google+, and Twitter.Freelance Writer: ShadowrunLatchkeys: Nevermore, Latchkeys: The Bootleg War, and Latchkeys: Roscoes in the Night are now available on Nook and Kindle.

  • Brandie Tarvin (6/23/2011)


    Dan-Ketil Jakobsen (6/23/2011)


    Thanks Brandie, that solved my issue. 🙂

    Which question solved your issue? I'm curious.

    Brandie.

    I had to ad the file name at the end.

    Dan

Viewing 10 posts - 1 through 9 (of 9 total)

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