我正在尝试使用Transfer对象复制表(结构而不是数据)。我不想复制列中的默认值,因为它们具有我不想在其中引用的存储过程,因此会导致传输崩溃。
有谁能告诉我如何复制表而不是默认约束?
Transfer transfer = new Transfer(sourceDatabase);
transfer.CopyAllObjects = false;
transfer.CopyData = false;
transfer.CopyAllTables = false;
transfer.DestinationDatabase = destinationDatabase.Name;
transfer.DestinationServer = sourceServer.Name;
foreach (Table sourceTable in sourceDatabase.Tables)
{
transfer.ObjectList.Add(sourceTable);
}
transfer.TransferData();
由于
答案 0 :(得分:0)
此代码仅使用主键,unyque键和索引复制表定义,但表之间没有任何关系。
Transfer transfer = new Transfer(sourceDatabase);
transfer.DestinationLoginSecure = sourceServer.DestinationLoginSecure;
transfer.DestinationLogin = sourceServer.ConnectionContext.Login;
transfer.DestinationPassword = sourceServer.ConnectionContext.Password;
transfer.DestinationDatabase = destinationDatabase.Name;
transfer.DestinationServer = sourceServer.Name;
transfer.CopyAllObjects = false;
transfer.CopyAllTables = false;
transfer.CopySchema = true;
transfer.DropDestinationObjectsFirst = true;
transfer.Options.WithDependencies = false;
transfer.Options.ContinueScriptingOnError = true;
transfer.Options.DriAll = false;
transfer.Options.DriDefaults = false;
transfer.Options.DriIndexes = true;
transfer.Options.DriPrimaryKey = true;
transfer.Options.DriUniqueKeys = true;
transfer.Options.DriForeignKeys = false;
transfer.Options.IncludeIfNotExists = true;
foreach (Table sourceTable in sourceDatabase.Tables)
{
transfer.ObjectList.Add(sourceTable);
}
transfer.TransferData();