How to Enable SQL Command Mode in SQL Server?

Error:

Incorrect syntax near ':'.

SQLCMD mode must be enabled to successfully execute this script.

 

Solution:

At times some of the SQL Scripts that you run might need the SQL Command Mode enabled to be able to execute successfully.

Its in such scenarios do you get the above Error which wants you to enable the SQLCMD mode.

Here is how you can enable the SQL CMD mode. In your SQL Server Management Studio

GoTo à Query Menu à SQLCMD Mode and click on it to enable it and you can click on to again to disable it.

Refer to Screenshot below.

Tags: