首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用SMO只复制数据

使用SMO只复制数据
EN

Stack Overflow用户
提问于 2021-05-11 17:05:39
回答 1查看 215关注 0票数 0

我试图仅使用SMO复制数据,并且在处理数据时出错

Microsoft.SqlServer.Management.Common.TransferException:传输数据时发生错误。有关详细信息,请参阅内部异常。( Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServer(DbDataReader阅读器))在D:\Source\atlas-cli\src\Commands\CopyDataCommand.cs:line 114中的D:\Source\atlas-cli\src\Commands\CopyDataCommand.cs:line 114中的D:\Source\atlas-cli\src\Commands\CopyDataCommand.cs:line 114中的CancellationToken sourceConnection、SqlConnection destinationConnection、TransferWriter writer、SqlTransaction事务)在Microsoft.SqlServer.Management.Smo.Transfer.TransferData() -内部异常堆栈跟踪的末端-在AtlasCLI.Commands.CopyDataCommand.CopyAllTablesData(CatalogSourceEndpoint源代码的Microsoft.SqlServer.Management.Smo.Transfer.TransferData() at AtlasCLI.Commands.CopyDataCommand.CopyAllTablesData(CatalogSourceEndpoint源文件中。

你可以在这里找到我的背景:

代码语言:javascript
复制
            var transfer = new Transfer(sourceServer.Databases[sourceConnection.Database])
            {
                Options =
                {
                    WithDependencies = true,
                    ContinueScriptingOnError = true,
                    AllowSystemObjects = true,
                    Indexes = true,
                    IncludeIfNotExists = true,
                    DriAll = true,
                    SchemaQualify = true,
                    ScriptSchema = false,
                    ScriptData = true
                },
                DestinationDatabase = destinationConnection.Database,
                DestinationServer = destinationServer.Name,
                DestinationLoginSecure = true,
                CopySchema = false,
                CopyData = true
        };

            transfer.DataTransferEvent += DataTransferEvent_Handler;
            transfer.DiscoveryProgress += DiscoveryProgress_Handler;
            transfer.ScriptingProgress += ScriptingProgressReport_Handler;
            transfer.ScriptingError += ScriptingErrorReport_Handler;
            transfer.TransferData();
EN

回答 1

Stack Overflow用户

发布于 2021-05-12 18:44:08

我需要更改目标数据库排序规则。

代码语言:javascript
复制
ALTER DATABASE [mydatabase] 
SET   SINGLE_USER
WITH  ROLLBACK IMMEDIATE
Go
ALTER DATABASE [mydatabase] COLLATE SQL_Latin1_General_CP1_CI_AI
Go
ALTER DATABASE [mydatabase] 
SET   MULTI_USER
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67491338

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档