SQL Server PRINT and Messages export to a .txt file
When executing IF/THEN
queries in SQL Server I am using a Print
Statement to let the user/myself know w开发者_如何学运维hat has happened.
Also when I run a query SQL Server mentions how many rows have been affected.
After searching I have only come across MySQL functions that allow PRINT
statements to be exported via SELECT into OUTFILE
. Does SQL Server have a way to send the PRINT
statements and or messages to a .txt file for logging?
If you run your script as a SQL Agent job, you can specify Output file
on the Advanced
settings of a step.
You don't have to use SQL Agent as a scheduler, you can run the job manually, or use sp_start_job
.
精彩评论