开发者

VS 2010 Database Project Run Script Conditionally

I am new to VS 2010 database projects, in the past I've used dbp projects but are not longer supported in VS 2010.

I would like to run a set of sql scripts that add 开发者_开发问答test data, but would ideally like this to only run based on the project configuration.

For example, if I can have a VS "Test" configuration that would execute this set of scripts.

I am currently using the PostDeployment.sql to add other scripts to run on post deployment.

Thanks for any help.


You'll want to set up variables for your project and then reference them when you do your build/deploy. For our case, we have a "DeployType" variable that can help us run certain scripts for certain environments.

In your post-deploy script, you'd use something like the following:

IF ( '$(DeployType)' = 'Test')
BEGIN
PRINT 'Running Post-Deploy Scripts for Test'

-- :r .\MyTestScript.sql
END
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜