sql - How to configure SQLServer DataTools project to be able to publish just views or stored procedures without comparing and deploying schema
问题描述
I have an existing database which is managed by someone else. I have sufficient rights to create some views or stored procedures. Unfortunatelly the database owner sometimes overwrites my changes and my views disappear. I want to create an SQL Server Database Project which then will allow me to just publish the views. I don't want to keep database schema in my project (it changes, it is huge and I don't care about it). I just want to have my views and sp and be able do deploy only them without comparing the schema. Is it possible?
解决方案
1)
将视图和存储过程放在一个项目中,将表放在另一个项目中,您使用“相同数据库”引用从第一个项目中引用。
只需部署带有视图/进程的 dacpac,不要将 IncludeCompositeProjects 设置为 true。
确保你没有启用 DropObjectsNotInSource,但这意味着如果你重命名或删除一个 proc/view,你需要手动删除它,但至少你不会删除表等
在投入生产之前对其进行正确测试:)
2)
您正在与“让这个数据库看起来像这个 dacpac”的 dacpac 模型作斗争,所以也许看看其他东西,准备好滚动或 flyway 或 dbup,在那里您仍然可以对您的代码进行源代码控制,但不必担心部署架构等。
如果您真的只需要更新视图和过程,那么您可以在其自己的文件中检查每个对象的源代码控制,例如:
create or alter xx
或者如果是旧版本的 sql:
if exists drop
其次是
create xx
使用类似 powershell 甚至 dos 批处理脚本来生成单个部署脚本:
ls -r *.sql | %{ "
r n---file $($_) ---
_n";cat $_} > ../deploy.sql
如果您需要更新的只是视图和存储的过程,那么您实际上是在实现梦想 :)
编
推荐阅读
- abap - RTTI:获取字符列的长度
- angular - Angular4中polyfills的含义是什么?
- cordova - 将 gtag.js 与 Cordova/Phonegap 一起使用
- javascript - 如何检测内容长度(响应大小)而不在 Nodejs 中接收响应?
- python - 获取诸如“cursor.execute”之类的错误不可下标,并且 cursor.fetchall() 不接受任何参数(2 govem)
- php - 我想过滤并让代码仅使用 FLOAT NUMBERS
- router - Angular 7:存在查询参数时不需要的重定向
- python - Python Max 函数 - 在字典中查找最大值
- unix - 如何纠正打开 cron 编辑器的错误?
- c++ - 在c ++中使用另一个.h文件中的类中的方法