【问题标题】:Using Scripts in Reference Db Project在参考数据库项目中使用脚本
【发布时间】:2016-02-24 13:24:04
【问题描述】:

我有一个包含公共表定义的基本 Sql Db 项目 (ProjectA),以及在这些表上设置触发器的脚本

然后我有另一个引用 ProjectA 的 Db 项目 (ProjectB)。

我想以某种方式从 ProjectB 中引用存储在 ProjectA 中的脚本,最好在我在 ProjectB 中的部署后脚本期间执行它。

这可能吗?

编辑:对 ProjectA 的引用是 .dacpac,而不是 .sqlproj。

【问题讨论】:

    标签: sql-server database-project


    【解决方案1】:

    您可以在部署后脚本中使用..\ 路径来引用数据库项目之外的文件。

    -- this script is in the same folder as the post-deploy script
    :r ".\script1.sql"
    
    -- this script is in the project's parent directory
    :r "..\..\..\script2.sql"
    

    【讨论】:

    • 对不起,我应该提到 - ProjectB 将 ProjectA 称为 .dacpac,而不是 .sqlproj - 所以我的文件系统上实际上没有脚本 .sql 文件,除了作为 .dacpac 中的一个项目
    猜你喜欢
    • 2012-01-23
    • 1970-01-01
    • 1970-01-01
    • 2011-03-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多