简体   繁体   English

如何将SQL Server数据库结构转移到另一台服务器

[英]How to transfer SQL Server DB structure to another server

Tell me please what's the best way to copy db structure to another server? 告诉我,将数据库结构复制到另一台服务器的最佳方法是什么?

I'm trying to generate a script in Management Studio and then run that script on the remote machine. 我正在尝试在Management Studio中生成脚本,然后在远程计算机上运行该脚本。 And I hate that thing. 我讨厌那件事。 It works unpredictable, you have to fix manually a lot of crap in the generated script. 它的工作原理不可预测,您必须在生成的脚本中手动修复很多废话。 I guess that isn't the best solution. 我猜那不是最好的解决方案。

Then I tried to generate SSIS package with DTSWizard.exe but I know nothing about that stuff, and I couldn't find a way to copy only the structure without data. 然后,我尝试使用DTSWizard.exe生成SSIS程序包,但是我对这些东西一无所知,而且我找不到一种方法来仅复制没有数据的结构。

Maybe there is a way somehow to break entire db structure into smaller pieces and work with them - first do all the tables, then views, then functions etc. 也许有一种方法可以将整个数据库结构分解为较小的部分并使用它们-首先执行所有表,然后执行视图,然后执行功能等。

Or there is another, normal way to do that without so much headache? 还是有另一种正常的方法来做到这一点而又不会太头痛呢?

Generating a script is the best solution. 生成脚本是最好的解决方案。 If you have to fix it manually, you are scripting it incorrectly. 如果必须手动修复它,则脚本编写有误。 Use the "Generate Scripts..." task in Management Studio 使用Management Studio中的“生成脚本...”任务

Be sure to check: 请务必检查:

  1. Are you generating the script for the appropriate version? 您是否正在为适当的版本生成脚本?
  2. Are you specifying "DROP and CREATE" and "IF EXISTS" options if running on an earlier version of the db? 如果在较早版本的数据库上运行,是否要指定“ DROP and CREATE”和“ IF EXISTS”选项?
  3. Are you scripting all the auxiliary objects (users, triggers, indexes, etc?) 您是否在编写所有辅助对象(用户,触发器,索引等)的脚本?

如果可以使用第三方工具,那么Red Gate SQL Compare是一个不错的工具。

Try DBSourceTools. 尝试使用DBSourceTools。 ( http://dbsourcetools.codeplex.com ) http://dbsourcetools.codeplex.com
Its open source, and specifically designed to script an entire database - tables, views, procs to disk, and then re-create that database through a deployment target. 它是开源的,专门用于编写整个数据库的脚本-表,视图,proc到磁盘,然后通过部署目标重新创建该数据库。
You can script all data, or just specify which tables to script data for. 您可以编写所有数据的脚本,也可以仅指定要为其编写脚本的表。
Additionally, you can zip up the results for distribution. 此外,您可以压缩结果以进行分发。
We use it for source control of databases, and to test update patches for new releases. 我们将其用于数据库的源代码控制,并测试新版本的更新补丁。
In the back-end it's built around SMO, and thus supports SQL 2000, 2005 and 2008. 它在后端围绕SMO构建,因此支持SQL 2000、2005和2008。
DBDiff is integrated, to allow for schema comparisons. DBDiff已集成,以允许进行模式比较。
Have fun, - Nathan. 玩得开心,-内森。

尝试使用SQL Examiner Suite: http : //www.sqlaccessories.com/SQL_Examiner_Suite/-您可以使用此工具复制架构和数据

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM