How to: Enable SQLCMD mode in the Transact-SQL Editor
The Transact-SQL editor can support the use of many SQLCMD commands in your scripts. You can toggle whether SQLCMD commands are executed or ignored. If you execute a script that contains SQLCMD commands when SQLCMD mode is off, a syntax error results. For more information about how to start the editor, see How to: Start the Transact-SQL Editor.
To toggle SQLCMD mode from the Data menu
Open the query in the Transact-SQL editor.
On the Data menu, point to Transact-SQL Editor, and click SQLCMD Mode.
To toggle SQLCMD mode from the toolbar
Open the query in the Transact-SQL editor.
On the Transact-SQL Editor toolbar, click SQLCMD Mode.
To toggle SQLCMD mode from the shortcut menu
Open the query in the Transact-SQL editor.
Right-click anywhere in the editor window, and then click SQLCMD Mode.