Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

ssms

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

like image 669
icecurtain Avatar asked Mar 02 '12 09:03

icecurtain


People also ask

How do you change the color of text in SSMS?

To change font color, size, and style in the EditorClick Options on the Tools menu. Click Environment, and then click Fonts and Colors. In the Show settings for list, select Text Editor. Change the font, size, display item, foreground and background colors.

What font is used in SQL?

The font must be a True Type fixed pitch font such as Courier New or Lucida Console. Enter the font size you want to use in pixels, such as 14, in the Value Data: field. SQL*Plus will use the new font size the next time you start the SQL*Plus Windows GUI.

How do you color text in SQL?

SQL Server Management Studio (SSMS) let you customize text properties as you like. Open SSMS, Go to Tools and then Options as shown below. Go to Environment and then click on Fonts and Colors. Under options you can make changes as you like.


1 Answers

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
like image 51
FreddieH Avatar answered Oct 04 '22 20:10

FreddieH