Навигация

Итоги года

Другие ссылки


Реклама

Счётчики


SQL Server Management Studio: "Incorrect syntax near ':'" on :setvar

22.07.2009 Среда 12:51

I had a database project generated in Visual Studio 2008. When built, this project generates a script file whose purpose is to re-create the database. When I was trying to run this script file in SQL Server Management Studio 2005, I received the following error:

Incorrect syntax near ':'.
... which ocurred on this line in the script:

:setvar DatabaseName "MyDB"
The solution was to turn on the so called "SQLCMD Mode" in the Management Studio. When this mode is on, the Management Studio does understand the ":setvar" syntax. To turn SQLCMD mode on go to menu Query, then check SQLCMD Mode item.