create report with date suffix

  • I need to create a report & run weekly to output to file on server with filename_date&timesuffix.txt.

    The original report (which is just procedure output) runs as a job.

    For security reasons, xp_cmdshell is disabled & I can't invoke a cmd script from jobs (to pop a suffix onto the end of the filename).

    What is the best & simplest way to do this?

    Thank you.

    🙂

    2005 sp4 ent

  • Is PowerShell installed on the server? You could do this in a CmdExec step type:

    %windir%\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy ByPass -Command "& {$x=(Get-Date -Format "yyyyMMdd_HHmmss");Move-Item -Path "C:\@\FlatFile.txt" -Destination "C:\@\FlatFile_$x.txt"}"

    Just change yyyyMMdd_HHmmss to match the timestamp format you want (see the options here) and the two paths to match your environment.

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

  • Hi, I'm sorry I forgot to say thanks.

    That's great. It's quite restricted where I work so we don't have ps on this server but I've been able to link it to another server that does & use your idea.

    I thought there would be a less convoluted way that going server to server for me, but, given the restrictions I have ... this way works so thank you.

    🙂

  • You're quite welcome. Thanks for posting back.

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

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

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