1

请告诉我将数据库结构复制到另一台服务器的最佳方法是什么?

我正在尝试在 Management Studio 中生成一个脚本,然后在远程计算机上运行该脚本。我讨厌那个东西。它的工作方式不可预测,您必须在生成的脚本中手动修复很多废话。我想这不是最好的解决方案。

然后我尝试使用 DTSWizard.exe 生成 SSIS 包,但我对这些东西一无所知,而且我找不到只复制没有数据的结构的方法。

也许有一种方法可以将整个数据库结构分解成更小的部分并使用它们 - 首先处理所有表,然后是视图,然后是函数等。

或者还有另一种正常的方法来做到这一点而不会那么头痛?

4

4 回答 4

5

生成脚本是最好的解决方案。如果您必须手动修复它,则说明您编写的脚本不正确。使用 Management Studio 中的“生成脚本...”任务

请务必检查:

  1. 您是否为适当的版本生成脚本?
  2. 如果在早期版本的数据库上运行,您是否指定“DROP 和 CREATE”和“IF EXISTS”选项?
  3. 您是否正在编写所有辅助对象(用户、触发器、索引等)的脚本?
于 2010-06-21T17:42:31.707 回答
2

如果可以接受 3rd 方工具,Red Gate SQL Compare 是一个很好的工具。

于 2010-06-21T17:39:10.807 回答
1

Try DBSourceTools. (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.
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.
DBDiff is integrated, to allow for schema comparisons.
Have fun, - Nathan.

于 2010-07-14T04:03:29.427 回答
0

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

于 2010-06-22T19:32:58.203 回答