Store executon time

  • Hi,

    I use to copy some files from one sever to another server.(LAN)

    I use xp_cmdshell command now i wanted to store the time taken to copy that files over the network.

    how can i do so.

    Thanx

    from

    killer

  • Just surround the call to xp_cmdshell with time measurment, like this:

    DECLARE @start DATETIME

    SET @start = GETDATE()

    EXEC master.dbo.xp_cmdshell 'command here'

    PRINT DATEDIFF(ms, @start, GETDATE())

  • Hi Chris,

    Thanx for ur reply.

    I modified and used in the process

    Declare @StartQueryTime varchar(10)

    Declare @EndQueryTime varchar(10)

    SELECT @StartQueryTime= LTRIM(STR(DATEPART(hour, GETDATE()))) + ':' +

      LTRIM(STR(DATEPART(minute, GETDATE()))) + ':' +

      LTRIM(STR(DATEPART(second, GETDATE())))

    Print @StartQueryTime

    exec master..xp_cmdshell 'copy \\ipadddress\txtdatafileforplanning\salestable.zip D:\FilecopyEpinav\Script_filecopy'

    SELECT @EndQueryTime= LTRIM(STR(DATEPART(hour, GETDATE()))) + ':' +

      LTRIM(STR(DATEPART(minute, GETDATE()))) + ':' +

      LTRIM(STR(DATEPART(second, GETDATE())))

    Print @EndQueryTime

    from

    Killer

     

  • A more simplified version:

    Print CONVERT(char(8), GETDATE(),14)

    exec master..xp_cmdshell 'copy \\ipadddress\txtdatafileforplanning\salestable.zip D:\FilecopyEpinav\Script_filecopy'

    Print CONVERT(char(8), GETDATE(),14)

    http://www.juliankuiters.id.au/article.php/t-sql-time-without-date


    Julian Kuiters
    juliankuiters.id.au

  • Hi Julian,

    Firstly u cannot use cast function like this as u have written.

    Error expected As with cast

    I need the execiution time of a query.Means when we execute a query in Query Analyser the execution time is shown in the status bar.

    The same i need as this time i have to calculate the exact time taken by a query.

    hope u understand.

    from

    Killer

     

  • ooops.. my bad.. that was supposed to be CONVERT not CAST. I've fixed up the prior post.

    Indeed, if you need to keep the times so you can use them for comparison later put them in a variable.

    I was replying more to the LTRIM(STR(DATEPART(hour, GETDATE()))) + ':' +

      LTRIM(STR(DATEPART(minute, GETDATE()))) + ':' +

      LTRIM(STR(DATEPART(second, GETDATE())))

    which can be simplified to CONVERT(char(8), GETDATE(),14)


    Julian Kuiters
    juliankuiters.id.au

  • Thanx for the help and support.

    from

    killer

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

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