stored Proc results to be logged as a file | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

stored Proc results to be logged as a file

Hello all, I have a big stored procedure which is going to alter many tables,insert data, basically lot of changes. So, i want to have a text file (or) any log file which will display, what all the changes does the stored procedure has done ( They dont want profiler output) Can anybody know how to log the results of execution of stored procedure to a text file. Thanks.
your can save all the chnages into a table and schedule a job to export the result to a txt file.

You can add print statements inside the procedure…
If you are running this procedure as a job you can youput the to text file…
Or As Link mentioned write the output to a table then export the table to a txt file using bcp…
You can also use OSQL to execute the procedure and write the output to a file..
MohammedU.
Microsoft SQL Server MVP
Moderator
SQL-Server-Performance.com All postings are provided “AS IS” with no warranties for accuracy.

Is this on SQL 2000 or 2005? Satya SKJ
Microsoft SQL Server MVP
Writer, Contributing Editor & Moderator
http://www.SQL-Server-Performance.Com
@http://www.askasqlguru.com/ This posting is provided AS IS with no rights for the sake of knowledge sharing. Knowledge is of two kinds. We know a subject ourselves or we know where we can find information on it.

Its SQL Server 2005 SP1. Like in Oracle there is spool, is there anything in sql server. Thanks.
BCP can be helpful to spool data to an external source.
If not this will work if xp_cmdshell is enabled
DECLARE @isqlString varchar(255)
SELECT @isqlString = ‘isql -Q "SELECT top 10 FROM TABLE" -E -o C:Results.txt’
EXEC master..xp_cmdshell @isqlString Satya SKJ
Microsoft SQL Server MVP
Writer, Contributing Editor & Moderator
http://www.SQL-Server-Performance.Com
@http://www.askasqlguru.com/ This posting is provided AS IS with no rights for the sake of knowledge sharing. Knowledge is of two kinds. We know a subject ourselves or we know where we can find information on it.
]]>