Enabling SQLCMD in a Visual Studio Transact SQL Script
So it’s pretty simple but, for some reason, the posts on MSDN that I initially read didn’t include this small but immensely important step. So, if you, like me, have added some SQLCMD statements to your pre or post deployment script, Visual Studio will likely have greeted you with:
SQL80001: Incorrect syntax near ‘:’.
Here’s how to overcome this:
From the SQL Menu
- Expand Execution Settings
- Select SQLCMD Mode
From the Transact SQL Editor
- Right click anywhere in the editor
- Select SQLCMD Mode