SQL Flow Field Guide

FORMATMESSAGE

Catalog support for SQL Server 2022 (16.x) and 2025 (17.x)

system function

What changes

Input
arguments or engine/session state
Output or change
value
Return type
nvarchar

Syntax at a glance

FORMATMESSAGE ( { msg_number | ' msg_string ' | @msg_variable} , [ param_value [ ,...n ] ] )

Work example

Format a message from a registered message id or format string.

Read state in the intended scope and immediately after the statement it describes. Treat host values as untrusted.

Check your work Use fixed templates and parameters rather than concatenating untrusted SQL text.

Open Microsoft Learn for full syntax, permissions, and details for your version.