sql print statement

  • Hello All,

    I am writing a sql query analyzer simulator/tool. I have a couple of stored procedures that will print status updates, using the SQL 'PRINT' statement. My code is written in java, and I use SimpleResultsets to process my results. Could anyone of you please give me some advice on how to get hold of the resulting output produced by the 'PRINT' statements in java? (maybe with the SimpleResultset or something similar?)

  • Not sure what you're wanting.

    Is the problem that the print statements (status messages) aren't coming back until the procedure is finished? If so, replace the print statements with the RaisError statement, ie:

    RaisError ('My status message', 10, 1) WITH NOWAIT

    The severity level is low enough to be an informational message (not fail the procedure), while the NOWAIT sends it immediately to the client.

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2

  • Hello Everyone,

    I posted this topic some time ago, and then got busy with something else...

    I would like for my PRINT statements in my stored procedures to be written to an output file, for trouble shooting purposes should something go wrong.

    Can anyone please give me an example or a link to an example of how this can be achieved?

    Any help greatly appreciated!

    Harriet

  • does anyone have any idea?;-)

  • Not sure how to do it in Java

    But I would make the SP output a return value instead of print.

    CREATE PROC p_ReturnValue

    @ReturnValue INT output

    AS

    SET @ReturnValue = 999

    RETURN @ReturnValue

    declare @returnvalue int

    execute p_ReturnValue @ReturnValue = @ReturnValue output

    select TestReturn= @ReturnValue

Viewing 5 posts - 1 through 4 (of 4 total)

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