6

I have a SQL Server 2008 Database Project that I'm attempting to deploy using Visual Studio 2010. When I click deploy, the build works fine, but after it creates the deployment script and begins to execute it, I get the following errors:

Error 8 SQL80001: 'DatabaseName' is not a recognized option.

Error 7 SQL80001: Incorrect syntax near ':'.

Looking at the deployment script, it has the following lines:

:setvar DatabaseName "DEV_DB"

...

GO

:on error exit

So it looks like SQL Server is not running the deployment script in SQLCMD mode to understand that syntax. If I'm copying and pasting into SSMS, I can set that option, but I want to deploy straight from Visual Studio. Where is the setting to have VS run this script in SQLCMD mode OR How can I set the script to not generate using SQLCMD syntax?

Thanks.

Community
  • 1
  • 1
Matt
  • 23,363
  • 39
  • 111
  • 152
  • Just to clarify, are you running the generated SQLCMD script interactively (i.e. through the VS query window) or is the Deploy step doing this for you? – Dan Nolan Sep 14 '12 at 02:52
  • It's running as part of the deployment. When I click Deploy, I believe it's generating the SQL script and deploying it in the same step. – Matt Sep 15 '12 at 23:23
  • That's odd. If you create a new db project from scratch, do you get the same error or does it only happen with this particular project? – Dan Nolan Sep 19 '12 at 16:06
  • 1
    possible duplicate of [Is it possible to make SQLCMD Mode 'Sticky' in Database Projects](http://stackoverflow.com/questions/22057776/is-it-possible-to-make-sqlcmd-mode-sticky-in-database-projects) – Tom W Apr 09 '15 at 09:36

0 Answers0