Results 1 to 1 of 1
  1. #1
    Join Date
    Aug 2009

    Question Unanswered: xcopy giving error....script for copying errorlogs

    i am getting output "Invalid path"....o files copied

    print @copycommand output is

    XCOPY "C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\Log\ErrorLog.1\" "D:\ErrorLog\"

    when i copy paste links , they open fine....our server is in domain and i am logged in with admin credentials......i am loggend in to sql server as same admin which has sysadmin i thik there shouldnt be security problems accessing programfiles folder

    declare @copycommand varchar(1000),
    @n int =1,
    @FOLDER varchar(1000),
    @fileDate varchar(200) =CONVERT(VARCHAR(20),GETDATE(),102)
    SET @FOLDER=' mkdir ' + '\\serverprod\D$\ErrorLog\'+ @fileDate
    EXEC xp_cmdshell @FOLDER, no_output

    while( @n < 20)

    SET @copycommand = 'XCOPY ' + '"C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\Log\ErrorLog.' + cast(@n as varchar(10)) + '\"'+ ' "D:\ErrorLog\"'

    set @n=@n+1
    print @copycommand
    EXEC xp_cmdshell @copycommand
    Last edited by amitwadhawan123; 08-14-11 at 11:14.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts