Print statement results altered in procedures

  • I have a stored procedure which uses print statements to display certain results. They display exactly as expected when that procedure is called by itself from SSMS. However, another procedure also makes a reference to this procedure.

    When the other procedure is run, the statements to be printed appear, but they are altered, Specifically, they are missing tabs and line breaks used to make them easier to read.

    Does anyone know why this would happen and if there is a way to stop it?

    ---
    Timothy A Wiseman
    SQL Blog: http://timothyawiseman.wordpress.com/

  • Are you calling both sps from SSMS?

    I know that results to grid will screw up the formating, but since you say you are printing that is most likely not the problem here.

  • i had a similar issue with an Oracle provider; the provider would strip out/replace CrLf and tabs with a space in a statement being executed...

    so a statment like this:

    SELECT STUFF,

    MORESTUFF --The accounting data blah blah dev notes

    FROM TABLENAME

    WHERE 1=OTHER STUFF

    would get processed as a single line like and the -- comment would cause an invalid statement, which was fine in QA/SSMS, but in the provider everything to the right of the comment marker gets ignored, and thus errored out. so no statement was added/processed...very annoying.

    it might be that the application that you are using is doing something similar except with the results being returned..., just as Remi is trying to determine...the same app should perform the same, so what's different?

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Can you imagine if the comment was in the where condition instead of the select???

    Angry boss to DBA >> why the heck didn't you test your sp before production, the table has been wiped out... and there's no backup of course at that point :P.

  • Ninja's_RGR'us (9/17/2008)


    Are you calling both sps from SSMS?

    I know that results to grid will screw up the formating, but since you say you are printing that is most likely not the problem here.

    Yes, this is all being done in SSMS. The carriage returns are present when I run it directly, but vanish from the displayed output when I call it within another stored procedure.

    Could it have something to do with the way print statements are buffered before display?

    ---
    Timothy A Wiseman
    SQL Blog: http://timothyawiseman.wordpress.com/

  • You got me there... I have no clue of what could be causing this.

    Any chance you can post the code along with DDL and sample data so that we can test it on our systems?

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

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