Microsoft.SqlServer.Management.Smo.Transfer()丢失约束

时间:2010-06-17 19:37:13

标签: c# smo transfer

我正在尝试将SQL数据库从一台服务器复制到另一台服务器。

请告诉我如何在不丢失目标数据库中的约束的情况下使用Transfer()方法。

我尝试了不同的参数,包括

 CopySchema = true;     // and 
 CopyAllSchemas = true; //and even 
 CopyAllObjects = true;

然而这个该死的东西正在失去所有的限制。

帮助我,请!

2 个答案:

答案 0 :(得分:2)

好的......

 transfer.Options.DriAll = true;

帮助。但现在它将所有触发器抛在后面

答案 1 :(得分:1)

在选项中有一些标志用于选择要复制的对象

  transfer.Options.Triggers = true;
  transfer.Options.Indexes = true;
  transfer.Options.Statistics = true;