将SQL Server数据库从测试部署到实时 [英] Deploying SQL Server Databases from Test to Live

查看:227
本文介绍了将SQL Server数据库从测试部署到实时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道你们如何管理2个SQL Server之间的数据库部署,特别是SQL Server 2005.
现在有一个开发和一个实时的。由于这应该是buildscript(标准Windows批处理,即使是当前这些脚本的复杂性)的一部分,所以我可能稍后会切换到PowerShell),企业管理器/管理Studio Express不计算。



你要复制.mdf文件并附加吗?在处理二进制数据时,我总是有点小心,因为这似乎是一个兼容性问题(尽管开发和实时应该始终运行相同版本的服务器)。


$ b $或者 - 由于T-SQL中缺少EXPLAIN CREATE TABLE - 您是否会将现有数据库导出到可在目标服务器上运行的SQL脚本?如果是,是否有一个工具可以自动将给定的数据库转储到SQL查询中,并从命令行运行? (再次,企业管理器/管理Studio Express不计算)。



最后 - 由于实时数据库已经包含数据,部署可能不涉及创建所有表,而是检查结构的差异和ALTER TABLE,而现在的字段改变时也可能需要数据验证/转换。



现在,我听到很多关于红门产品的好东西,但对于爱好项目,价格是有点陡峭。



那么你在使用自动从测试到自动部署SQL Server数据库呢?

解决方案

我已经把所有的DDL(创建/改变/删除)语句手动编码,将它们添加到我的.sln作为文本文件,并使用正常的版本控制(使用subversion,但任何修订控制都应该工作)。这样,我不仅可以获得版本控制的好处,而且还可以从dev / stage更新,代码和数据库标签,分支等工作都是一样的。



否则,我同意redgate是昂贵的,如果你没有一家公司为您购买。如果可以让一家公司为您购买,那真的是值得的!


I wonder how you guys manage deployment of a database between 2 SQL Servers, specifically SQL Server 2005. Now, there is a development and a live one. As this should be part of a buildscript (standard windows batch, even do with current complexity of those scripts, i might switch to PowerShell or so later), Enterprise Manager/Management Studio Express do not count.

Would you just copy the .mdf File and attach it? I am always a bit careful when working with binary data, as this seems to be a compatiblity issue (even though development and live should run the same version of the server at all time).

Or - given the lack of "EXPLAIN CREATE TABLE" in T-SQL - do you do something that exports an existing database into SQL-Scripts which you can run on the target server? If yes, is there a tool that can automatically dump a given Database into SQL Queries and that runs off the command line? (Again, Enterprise Manager/Management Studio Express do not count).

And lastly - given the fact that the live database already contains data, the deployment may not involve creating all tables but rather checking the difference in structure and ALTER TABLE the live ones instead, which may also need data verification/conversion when existing fields change.

Now, i hear a lot of great stuff about the Red Gate products, but for hobby projects, the price is a bit steep.

So, what are you using to automatically deploy SQL Server Databases from Test to Live?

解决方案

I've taken to hand-coding all of my DDL (creates/alter/delete) statements, adding them to my .sln as text files, and using normal versioning (using subversion, but any revision control should work). This way, I not only get the benefit of versioning, but updating live from dev/stage is the same process for code and database - tags, branches and so on work all the same.

Otherwise, I agree redgate is expensive if you don't have a company buying it for you. If you can get a company to buy it for you though, it really is worth it!

这篇关于将SQL Server数据库从测试部署到实时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆