xp_cmdshell

  • I need to copy translogs from one server to another.

    I have the xcopy command that work directly in the cmd prompt, but if I try and excute it via Query Analyzer I get an invalid path error. What am I missing?

    xcopy \\111.111.11.30\g$\\Hourly_Tran_Backup\  \\111.111.11.31\f$\mssql\hourly_tran_backup\ /Y

  • Look at your syntax after q$, you have two slashes. \\

    Also, you may have to enclose the folder name in either brackets or double quotes when they have spaces in the name.

    Mark

  • You need to check which OS account your SQL Server Service runs as. More than likely it can't authenticate to either the source or the destination.

    A "net use" may well suffice.

  • two slashes is fine for unc paths if your moving stuff across servers, like in this example. And as pkirk suggests, check that the sql service accounts (run services.msc >then check properties on MSSQLServer & SqlAgent) have sufficient rights to run the command. usually, with copying data across servers you will find that you need to use a domain account that has sufficient access rights to both servers for the transaction to work.

  • Salim,

    I'm not sure if your response is referencing my post, if so, it's not the two slashes at the beginning of the string that's a problem.  You are correct that this the format for a UNC path.  Look closer at the string, I suspect it's a cut and paste typo that added the extra slash after the q$.

    Mark

  • the extra two slashes should be OK. Windows will just ignore them.

  • missed that one Mark, quite right too.

  • Enclose the complete paths in double quotes since there are spaces enclosed.

    Start with a simple notepad file when it works move on to the files you need to move

    xcopy

    "***Microsoft sql server "  

    "****Microsoft sql server ****"

     

     

    Mike

Viewing 8 posts - 1 through 7 (of 7 total)

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