database项目未运行Post Deployment脚本

时间:2013-06-07 10:12:00

标签: sql-server visual-studio-2012 database-project sql-server-data-tools

我们有一个包含三个数据库项目的解决方案。所有三个生产的dacpac都按顺序部署,但由于某些原因,其中一个dacpacs没有运行部署后的脚本。

我们正在使用sqlpackage创建一个diffscript,而diffscript 正确地包含了部署后的语句..这里是一个片段

IF EXISTS (SELECT * FROM #tmpErrors) ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT>0 BEGIN
PRINT N'The transacted portion of the database update succeeded.'
COMMIT TRANSACTION
END
ELSE PRINT N'The transacted portion of the database update failed.'
GO
DROP TABLE #tmpErrors
GO
/*
Post-Deployment Script Template                         
--------------------------------------------------------------------------------------
 This file contains SQL statements that will be appended to the build script.       
 Use SQLCMD syntax to include a file in the post-deployment script.         
 Example:      :r .\myfile.sql                              
 Use SQLCMD syntax to reference a variable in the post-deployment script.       
 --------------------------------------------------------------------------------------
*/
print 'SCRIPT: dbo.MEMTYPES.data.sql'

其中: a)Comment位于Header postdeployment.sql脚本中,该脚本使用标准语法调用其他脚本:: r。\ dbo.MEMTYPES.data.sql,以及 b)“print'SETIPT:dbo.MEMTYPES.data.sql'”行是postdeployment脚本中定义的第一个子脚本的第一行。

但是,运行时,部署日志以行:

结束
The transacted portion of the database update succeeded.

这意味着应用了dacpac架构更改(并且它们是),但可能没有尝试继续在脚本中运行部署后任务。

有什么想法吗?

2 个答案:

答案 0 :(得分:3)

因为我发布问题后的几个月,http://blog.stackoverflow.com/2011/07/its-ok-to-ask-and-answer-your-own-questions/我想我应该说明结果是什么......

除了删除解决问题的评论之外,我找不到押韵或理由。既然这已经包含在我们要遵循的规则中,那么我们就没有遇到过这个问题了。

答案 1 :(得分:0)

正如上面提到的 user3683706,部署后脚本的 Build Action 必须是 PostDeploy(如下面所选文件所示)。并且只能有一个部署后脚本。

如果您想要多个脚本怎么办?您可以像这样在一个脚本中引用它们

:r .\Post-Deployment_Scripts\Events.sql

enter image description here

如果有任何问题,请告诉我!不胜感激!

相关问题