A general logging t-sql process to write to .txt files

In my previous article, I walked you through a general logging process to write out simple logging information to a table so that it could read/reported on, etc. You can see it be clicking here. But I actually got a few responses from people who want to be able to log directly to .txt files.

I thought about for a while… My initial thought was to write all of the log stuff out to a temporary table then bcp it out… but I figured that could be overkill and potentially cumbersome to implement, especially if the .txt file you want write to already exists. So I thought about it a little more came up with this simple variation on my table-based logging process that will allow you to write logging information to general .txt files. This could be used any place T-SQL is welcome (stored procedures, query windows, triggers, and SQL Query Windows within DTS).

Here I’ll outline: The process, Why it works, Caveats

Get the Free Newsletter!

Subscribe to Cloud Insider for top news, trends & analysis

Latest Articles