xp_cmdshell error

  • hi all,

    trying to copy data file from one server to another, but I get a syntax error.

    this is the code that I'm using:

    exec master..xp_cmdshell 'copy H:\Data\MSSQL\Data\Lennar_CFT.mdf \\ldc-dba-sql-ga\c$\Program Files\Microsoft SQL Server\MSSQL\Data'

    this is the error:

    The syntax of the command is incorrect.

    can someone look at this and tell me what I'm doing wrong?

    thanks in advance

  • Due to the space in the file name, you need to put it in double quotes:

     

    exec master..xp_cmdshell 'copy H:\Data\MSSQL\Data\Lennar_CFT.mdf "\\ldc-dba-sql-ga\c$\Program Files\Microsoft SQL Server\MSSQL\Data"'

     

    like that.

    Lynn

     

  • thank you Lynn

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

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