Change Font/Color print error_message() inside cursor?

  • Can someone say is it possible to change font or color in the output. My sql statement is print error_message(), so whenever it prints this i want it to be in different color or font. Please advice. thnaks

  • if you are talking about the color of the results in the message panel in SSMS, the only thing you can change is the font size and font type; the colors being used for error messages is not exposed.

    SSMS>>Tools>>Options

    Environment>>Fonts and Colors

    drop down menu for "Text Results"

    only thing exposed is font type and size.

    this affects the font for both results and error messages.

    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!

  • thanks, but i want the the message ONLY from "print error_message()" to be printed in different font. I am using this in a cursor inside try/catch block and i wouldn't know when an error occured since the entire result is in same font.

  • nope, the font is not dynamically exposed either, even though a richtextbox is being used to display the data;

    about the only thing you could do is use a try catch,and wrap it with thins like this to make it more obvious when reviewing a long file;

    you could also simply use the search feature for "error" and find each item one by one.

    --assuming inside your cursor

    BEGIN TRY

    Begin Transaction

    <do something in cursor>

    Commit transaction

    END TRY

    BEGIN CATCH

    DECLARE

    @ErrorSeverity INT,

    @ErrorNumber INT,

    @ErrorMessage NVARCHAR(4000),

    @ErrorState INT

    SET @ErrorSeverity = ERROR_SEVERITY()

    SET @ErrorNumber = ERROR_NUMBER()

    SET @ErrorMessage = ERROR_MESSAGE()

    SET @ErrorState = ERROR_STATE()

    PRINT '--################### ERROR BEGINS ##################'

    PRINT @ErrorMessage

    PRINT '--################### ERROR ENDS ####################'

    END CATCH

    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!

  • that's what i exactly did, just wanted to see if there is a better way. Thanks

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

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