sealz
sealz

Reputation: 5408

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 what 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?

Upvotes: 0

Views: 3798

Answers (1)

Andomar
Andomar

Reputation: 238126

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.

Upvotes: 1

Related Questions