VS 2008 Database Project - During Deploy 'Data

2019-08-03 18:46发布

问题:

I am using VS 2008 and have inhertied a database project that I am trying to deploy. The deploy I am doing is to a new database. (as if I were setting up a new installation)

The Deploy Action is: Create Scrip and deploy to Database.

I get the following error: Schema.dbschema(0,0)Error TSD01268: SQL Execution error: A fatal error occurred. The variable DatabaseName could not be found.

The DatabaseName is defined in the project properties.

If I look a the deployment script I see the declaration is commented out. I can remove the comment and run the script manualy and it works, but when I regenerate the script the declaration is commented out again.

/*
:setvar DatabaseName "TestDb"
:setvar DefaultDataPath "C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\"
*/
GO

I have searched for a setting that would cause the declaration to be commented out, but haven't found anything.

I want to be able to run the deployment script without editing it everytime.

回答1:

Found it!

In Database.sqldeployment there is an option under Advanced Options called "CommentOutSetVarDeclarations".



回答2:

Have you specified in the project settings that you wish to always re-create the database when deploying? IF not, try setting this option to see if that resolves this for you. See this MSDN article for more details.