How to get T-SQL PRINT messages to an output file

  • The PRINT debug messages from my top-level stored proc are getting piped to my OUTPUT file, however any child procs are not getting piped to the same output file.

    EXAMPLE:

    I have the following SQLCMD command running a command prompt with -o output param:

    sqlcmd -S %myServer% -E -d testDB-Q "exec dbo.sp_Testme" -o Output\Test_All.log

    I noticed that the PRINT messages from my "sp_Testme" stored proc are successfully getting outputted to the Test_All.log file; however, sp_Testme makes an additional stored procedure call to "sp_Testme_Details" .

    The problem is that any PRINT message in "sp_Testme_Details" are NOT making it into my Test_All.log output file.

    Am I missing out on something ?

    Thank you,

    Bob

  • Hi Bob,

    Can you provide more information? You should be able to write the output from the inner stored proc to the file. Have you tried to eliminate the code around the print statement. Create a test and start with 2 stored proc that only write the PRINT output and have one call the other and see if that works. If it doesn't work you know it isn't code related/ If it does then you can introduce each existing stored proc one at a time and test to see where it breaks and try and isolate it.

    Thanks,

    Bill

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply