:Setvar
Set a text value used by sqlcmd script substitution.
Syntax at a glance
:Setvar name [ "value" ]
Work example
Reuse a script for a known lab month
Set an illustrative month variable and reference it in a small SELECT. Review the expanded value before running scripts with substituted identifiers.
Check your work The result shows the chosen month. Treat scripting variables as text substitution when reviewing inputs.
Open Microsoft Learn for full syntax, permissions, and details for your version.