Reputation: 675
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
Upvotes: 7
Views: 17817
Reputation: 11
In the new version of SQL Server, the RAISERROR function is not available, but you can use THROW instead. It works similarly. However, it is a bit more extensive. For details, please refer to the documentation:
Upvotes: 0
Reputation: 813
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
Upvotes: 39