Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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)"
share|improve this question

1 Answer 1

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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