Creation of default data in Visual Studio database projects / SQL Server(在 Visual Studio 数据库项目/SQL Server 中创建默认数据)
问题描述
有没有办法在VS 2010的数据库项目中使用数据生成计划来创建一组默认数据?或者我是在吠错树,即数据生成计划最适合创建虚拟示例数据吗?
Are there way to using data generation plans in VS 2010's database projects to create a set of default data? Or am I barking up the wrong tree i.e. are data generation plans best suited to create dummy example data?
我们有一堆数据(默认设置、默认用户等)需要为每个数据库部署创建.如果有工具可以帮助我们解决这个问题,那就太好了,这样就可以进行源代码控制和更好的管理.
We have a bunch of data (default settings, default users etc etc) that needs to be created for each database deployment. It would be nice to have tooling to help us with this, so it can be source controlled and better managed.
我猜可能有第三方替代品,但我希望有一个内置的 Visual-Studio-Way 做事方式,因此它可以与 TFS 等很好地集成.
I'm guessing that there are probably third party alternatives, but I'm hoping there is a built-in Visual-Studio-Way of doing things, so it can integrate nicely with TFS etc.
推荐答案
可能有不同的方法来做到这一点,但基本的是:
There are probably different ways to do this, but the basics are to:
- 创建一个插入默认数据的脚本
- 编辑 Script.PostDeployment.sql 脚本以使用您的脚本插入默认值
例如,我在项目的 Scripts->Post-Deployment 文件夹下创建了一个新文件夹 DefaultData,并在此处添加了用于插入默认数据的脚本 InsertDefaultData.sql.然后,我将以下行添加到 Script.PostDeployment.sql ":r ..\DefaultData\InsertDefaultData.sql".
For example, I created a new folder, DefaultData, under the Scripts->Post-Deployment folder of my project and added my script for inserting the default data here, InsertDefaultData.sql. Then, I added the following line to Script.PostDeployment.sql ":r ..\DefaultData\InsertDefaultData.sql".
这篇关于在 Visual Studio 数据库项目/SQL Server 中创建默认数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 Visual Studio 数据库项目/SQL Server 中创建默认数


基础教程推荐
- while 在触发器内循环以遍历 sql 中表的所有列 2022-01-01
- 如何在 CakePHP 3 中实现 INSERT ON DUPLICATE KEY UPDATE aka upsert? 2021-01-01
- MySQL 5.7参照时间戳生成日期列 2022-01-01
- 使用 VBS 和注册表来确定安装了哪个版本和 32 位 2021-01-01
- 带有WHERE子句的LAG()函数 2022-01-01
- MySQL根据从其他列分组的值,对两列之间的值进行求和 2022-01-01
- ORA-01830:日期格式图片在转换整个输入字符串之前结束/选择日期查询的总和 2021-01-01
- 从字符串 TSQL 中获取数字 2021-01-01
- 带更新的 sqlite CTE 2022-01-01
- CHECKSUM 和 CHECKSUM_AGG:算法是什么? 2021-01-01