export results to a text file

  • Hi, if I schedule a job to run a DBCC command for example 'DBCC UPDATEUSAGE('db1')', is there a way to export the result to a txt file? If yes, can it include datetimestamp in the filename too?

    Thanks in advance.

  • Go to Steps tab of the job, then double click on a step, click on Advanced tab, find a box called "Transact-SQL Script (TSQL) command Options" and Output File entry box under it. You can ether append or override the log file from here.

  • Thanks, Mromm. Really appreciate it. But too bad it can't have a datetimestamp in the filename like what database maintenance plan does.

  • That's the way I do it.

    To get the datetimestamp, just incluse an extra select statement before your dbcc command, as ALL output from the job gets written to the file. Course that won't give you different filenames.

    A way to do that is to store your dbcc results using the option for table, and bcp them to a filename generated by the proc doing it.

    Edited by - scorpion_66 on 01/02/2003 5:15:07 PM

    Edited by - scorpion_66 on 01/02/2003 5:21:32 PM

  • You can also put a DOS command 'rename' or 'copy' as the last step of your job and rename/copy the output file using the date/time as you wish.

    Edited by - mromm on 01/02/2003 5:47:00 PM

  • Now that's great. Really. I have stored procs that rename archive files for me, and have never thought of doing that. (knocks on head) I write code in statement boxes all the time, just like it was QA (up to the text limit), I call procs from it all the time, and I flat out have never thought of that.

    Betcha can't guess what I'm doing to some of my jobs tomorrow.....

  • Cool, thanks for the info.

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

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