I'm running batch processes via a batch file and I want SQL server to log the reslt when I execute my DBCC SHRINKFILE command from my batch file. Is there anyway to do this?

Example: - Run.bat

rem Shrink transaction log and log the result

"C:\Program Files\Microsoft SQL Server\100\Tools\Binn\osql.exe" -E -Q "Use [Database] DBCC SHRINKFILE(Database_log, 50)"
link|improve this question
feedback

1 Answer

up vote 2 down vote accepted

If you're just trying to log it to a text file you can do something like the following:

"C:\Program Files\Microsoft SQL Server\100\Tools\Binn\osql.exe" -E -Q "Use [Database] DBCC SHRINKFILE(Database_log, 50)" >> C:\ShrinkFile.LOG

The >> will append or > to overwrite.

If you want SQL server to actually log it in the error log then I would suggest looking into a trace flag that would handle that.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.