Font colour (color) used in SQL Server Management Studio (SSMS)

13,458

It's a bit of an old post, but if you still want to be able to display your text in red: use the built in RAISERROR function. You can set the severity of the error and that will determine if it outputs your text in black or red. For example:

raiserror('Your error message', 10, 0)

Will display the error with just the black font color

raiserror('Your error message', 11, 0)

Will display the error with a red font color

Message severity of 10 or lower will use black font color, 11 or higher will use red font color.

For completion: message severity of 20 or higher will stop executing the rest of the script, and if you use a message severity of 19 or higher you have to call the raiserror function with the log option, like so:

 raiserror('Your error message', 20, 0) with log
Share:
13,458
icecurtain
Author by

icecurtain

New Bee ..

Updated on June 24, 2022

Comments

  • icecurtain
    icecurtain about 2 years

    It is possible to change the default font colour (color) used in SQL Server Management Studio (SSMS) in the messages pane output, via a SQL print command?

    IF @@TRANCOUNT>0 BEGIN
    PRINT 'The database update succeeded'
    COMMIT TRANSACTION
    END
    ELSE PRINT 'The database update failed'
    GO
    

    I.e

    enter image description here