SQL Server 2016 复制数据库向导错误
SQL Server 2016 Copy Database wizard error
我正在尝试将 SQL 服务器数据库从 sql 服务器 2016 开发版复制到 SQL 服务器 2014 开发版。
失败并显示以下日志:
#Fields: event,computer,operator,source,sourceid,executionid,starttime,endtime,datacode,databytes,message
OnInformation,PAPERLESS-PRIME,NT AUTHORITY\NETWORK SERVICE,PAPERLESS-PRIME_PAPERLESS-PRIME_SQLEXPRESS_Transfer Objects Task,{F858F211-3783-40F8-9C7A-B477576706D4},{AB42BFE8-D674-4E86-ACEA-FA89BFF7E8BE},8/8/2016 11:40:52 AM,8/8/2016 11:40:52 AM,0,0x,Transferring database callmanager_pwc from PAPERLESS-PRIME server as callmanager_pwc to PAPERLESS-PRIME\SQLEXPRESS server
OnInformation,PAPERLESS-PRIME,NT AUTHORITY\NETWORK SERVICE,CDW_PAPERLESS-PRIME_PAPERLESS-PRIME_SQLEXPRESS_2,{2BE0FC74-D66D-4AFE-895F-B0CC80E7C848},{AB42BFE8-D674-4E86-ACEA-FA89BFF7E8BE},8/8/2016 11:40:52 AM,8/8/2016 11:40:52 AM,0,0x,Transferring database callmanager_pwc from PAPERLESS-PRIME server as callmanager_pwc to PAPERLESS-PRIME\SQLEXPRESS server
OnInformation,PAPERLESS-PRIME,NT AUTHORITY\NETWORK SERVICE,PAPERLESS-PRIME_PAPERLESS-PRIME_SQLEXPRESS_Transfer Objects Task,{F858F211-3783-40F8-9C7A-B477576706D4},{AB42BFE8-D674-4E86-ACEA-FA89BFF7E8BE},8/8/2016 11:40:52 AM,8/8/2016 11:40:52 AM,0,0x,Added data file callmanager in path C:\SQLDB14\callmanager_pwc.mdf to file group [PRIMARY]
OnInformation,PAPERLESS-PRIME,NT AUTHORITY\NETWORK SERVICE,CDW_PAPERLESS-PRIME_PAPERLESS-PRIME_SQLEXPRESS_2,{2BE0FC74-D66D-4AFE-895F-B0CC80E7C848},{AB42BFE8-D674-4E86-ACEA-FA89BFF7E8BE},8/8/2016 11:40:52 AM,8/8/2016 11:40:52 AM,0,0x,Added data file callmanager in path C:\SQLDB14\callmanager_pwc.mdf to file group [PRIMARY]
OnInformation,PAPERLESS-PRIME,NT AUTHORITY\NETWORK SERVICE,PAPERLESS-PRIME_PAPERLESS-PRIME_SQLEXPRESS_Transfer Objects Task,{F858F211-3783-40F8-9C7A-B477576706D4},{AB42BFE8-D674-4E86-ACEA-FA89BFF7E8BE},8/8/2016 11:40:52 AM,8/8/2016 11:40:52 AM,0,0x,Added log file callmanager_log in path C:\SQLDB14\callmanager_pwc.ldf
OnInformation,PAPERLESS-PRIME,NT AUTHORITY\NETWORK SERVICE,CDW_PAPERLESS-PRIME_PAPERLESS-PRIME_SQLEXPRESS_2,{2BE0FC74-D66D-4AFE-895F-B0CC80E7C848},{AB42BFE8-D674-4E86-ACEA-FA89BFF7E8BE},8/8/2016 11:40:52 AM,8/8/2016 11:40:52 AM,0,0x,Added log file callmanager_log in path C:\SQLDB14\callmanager_pwc.ldf
OnInformation,PAPERLESS-PRIME,NT AUTHORITY\NETWORK SERVICE,PAPERLESS-PRIME_PAPERLESS-PRIME_SQLEXPRESS_Transfer Objects Task,{F858F211-3783-40F8-9C7A-B477576706D4},{AB42BFE8-D674-4E86-ACEA-FA89BFF7E8BE},8/8/2016 11:40:52 AM,8/8/2016 11:40:52 AM,0,0x,Transferring data to database callmanager_pwc from callmanager_pwc
OnInformation,PAPERLESS-PRIME,NT AUTHORITY\NETWORK SERVICE,CDW_PAPERLESS-PRIME_PAPERLESS-PRIME_SQLEXPRESS_2,{2BE0FC74-D66D-4AFE-895F-B0CC80E7C848},{AB42BFE8-D674-4E86-ACEA-FA89BFF7E8BE},8/8/2016 11:40:52 AM,8/8/2016 11:40:52 AM,0,0x,Transferring data to database callmanager_pwc from callmanager_pwc
OnError,PAPERLESS-PRIME,NT AUTHORITY\NETWORK SERVICE,PAPERLESS-PRIME_PAPERLESS-PRIME_SQLEXPRESS_Transfer Objects Task,{F858F211-3783-40F8-9C7A-B477576706D4},{AB42BFE8-D674-4E86-ACEA-FA89BFF7E8BE},8/8/2016 11:40:54 AM,8/8/2016 11:40:54 AM,0,0x,Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
StackTrace: at System.Collections.BitArray.Set(Int32 index, Boolean value)
at Microsoft.SqlServer.Management.Smo.PermissionWorker.GetPermissionSetBase(PermissionEnumKind kind, Int32 i)
at Microsoft.SqlServer.Management.Smo.SqlSmoObject.GetPermissionsFromCache(PermissionEnumKind kind)
at Microsoft.SqlServer.Management.Smo.SqlSmoObject.AddScriptPermissions(StringCollection sc, PermissionEnumKind kind, ScriptingPreferences sp)
at Microsoft.SqlServer.Management.Smo.ScriptMaker.ScriptCreateSpecialUrn(Urn urn, ScriptingPreferences sp, ObjectScriptingType& scriptType)
at Microsoft.SqlServer.Management.Smo.ScriptMaker.ScriptCreate(Urn urn, ScriptingPreferences sp, ObjectScriptingType& scriptType)
at Microsoft.SqlServer.Management.Smo.ScriptMaker.ScriptCreateObjects(IEnumerable`1 urns)
at Microsoft.SqlServer.Management.Smo.ScriptMaker.ScriptUrns(List`1 orderedUrns)
at Microsoft.SqlServer.Management.Smo.ScriptMaker.DiscoverOrderScript(IEnumerable`1 urns)
at Microsoft.SqlServer.Management.Smo.ScriptMaker.ScriptWorker(List`1 urns, ISmoScriptWriter writer)
at Microsoft.SqlServer.Management.Smo.DataTransferBase.GetScriptLoadedTransferWriter()
at Microsoft.SqlServer.Management.Smo.Transfer.TransferData()
at Microsoft.SqlServer.Dts.Tasks.TransferObjectsTask.TransferObjectsTask.TransferDatabasesUsingSMOTransfer()
OnError,PAPERLESS-PRIME,NT AUTHORITY\NETWORK SERVICE,CDW_PAPERLESS-PRIME_PAPERLESS-PRIME_SQLEXPRESS_2,{2BE0FC74-D66D-4AFE-895F-B0CC80E7C848},{AB42BFE8-D674-4E86-ACEA-FA89BFF7E8BE},8/8/2016 11:40:54 AM,8/8/2016 11:40:54 AM,0,0x,Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
StackTrace: at System.Collections.BitArray.Set(Int32 index, Boolean value)
at Microsoft.SqlServer.Management.Smo.PermissionWorker.GetPermissionSetBase(PermissionEnumKind kind, Int32 i)
at Microsoft.SqlServer.Management.Smo.SqlSmoObject.GetPermissionsFromCache(PermissionEnumKind kind)
at Microsoft.SqlServer.Management.Smo.SqlSmoObject.AddScriptPermissions(StringCollection sc, PermissionEnumKind kind, ScriptingPreferences sp)
at Microsoft.SqlServer.Management.Smo.ScriptMaker.ScriptCreateSpecialUrn(Urn urn, ScriptingPreferences sp, ObjectScriptingType& scriptType)
at Microsoft.SqlServer.Management.Smo.ScriptMaker.ScriptCreate(Urn urn, ScriptingPreferences sp, ObjectScriptingType& scriptType)
at Microsoft.SqlServer.Management.Smo.ScriptMaker.ScriptCreateObjects(IEnumerable`1 urns)
at Microsoft.SqlServer.Management.Smo.ScriptMaker.ScriptUrns(List`1 orderedUrns)
at Microsoft.SqlServer.Management.Smo.ScriptMaker.DiscoverOrderScript(IEnumerable`1 urns)
at Microsoft.SqlServer.Management.Smo.ScriptMaker.ScriptWorker(List`1 urns, ISmoScriptWriter writer)
at Microsoft.SqlServer.Management.Smo.DataTransferBase.GetScriptLoadedTransferWriter()
at Microsoft.SqlServer.Management.Smo.Transfer.TransferData()
at Microsoft.SqlServer.Dts.Tasks.TransferObjectsTask.TransferObjectsTask.TransferDatabasesUsingSMOTransfer()
OnProgress,PAPERLESS-PRIME,NT AUTHORITY\NETWORK SERVICE,PAPERLESS-PRIME_PAPERLESS-PRIME_SQLEXPRESS_Transfer Objects Task,{F858F211-3783-40F8-9C7A-B477576706D4},{AB42BFE8-D674-4E86-ACEA-FA89BFF7E8BE},8/8/2016 11:40:55 AM,8/8/2016 11:40:55 AM,0,0x,Database transfer failed for 1 database(s).
请问这是产品的问题,还是我做错了什么?
这里有点晚了,但希望这对其他人有所帮助。我收到了类似的问题,并将两台服务器都更新到最新的 CU 为我修复了它。
我知道实现此目标的唯一正确方法是从较高版本的 SQL 服务器生成脚本,并在较低版本的 运行 上生成脚本。为此,请按照以下步骤操作:
- 打开 SQL Server Management Studio
- 右键单击您正在使用的数据库。
- 选择任务 > 生成脚本
- 您将看到一个向导屏幕,在介绍中您可以单击下一步。
- 选择是对整个数据库和对象编写脚本还是对它们单独select。我喜欢把它作为第一个选项,一切。点击下一步
- 在输出类型中,选择将脚本保存到特定位置
- 保存到文件
- 点击高级
- 服务器版本脚本
- 选择你要的版本,我的是2012
- 要编写脚本的数据类型 - 架构和数据
- 保持其他设置不变。
- 点击确定
- 要生成的文件 - 单个文件
- 文件名 - 为脚本命名,扩展名为 .sql
- 另存为 Unicode 文本
- 点击下一步
- 使用加号打开选项
- 检查摘要中的设置是否全部正常 - 您主要查看要编写脚本的版本和数据类型
- 点击下一步
- 等待 运行,如果成功,您应该会一直看到绿色的勾号。
- 点击完成
- 然后转到您保存脚本的位置。
- 打开脚本
- 确保 .mdf 和 log.ldf 文件的文件路径正确。
- 运行 脚本
- 您可能会遇到如下错误:
无法添加主体 'CodeShare',因为它不存在或您没有权限
忽略这一点很好。它从来没有给我带来问题。
步骤取自this article,帮了我很多次。
如果您的脚本包含大量数据,您可以使用 CMD 加载它:
- 打开命令提示符 window。
- 在命令提示符 window 中,键入:
sqlcmd -S myServer\instanceName -i C:\myScript.sql
- 按 ENTER。
步骤2中的路径当然只是简单示例。
另一种方法是只编写没有数据的数据库模式脚本,并在具有较低版本 SQL 服务器的目标服务器上重新创建它。接下来,您可以使用 SSMS 连接到两个实例并将数据从一个实例复制到另一个实例,但是如果您定义了表之间的关系,则必须记住正确的复制顺序。在这种情况下,删除关系并重新创建它们可能是一个很好的策略(请记住,您在生成的脚本中获得了它们)。
这样做的另一个陷阱是主 key/identity 列 - 默认设置阻止将数据插入此类列,但您可以实现此 运行ning 命令:
SET IDENTITY_INSERT dbo.YourTableName ON;
插入成功后你还应该运行:
SET IDENTITY_INSERT dbo.YourTableName OFF;
希望本手册对您有所帮助。
我正在尝试将 SQL 服务器数据库从 sql 服务器 2016 开发版复制到 SQL 服务器 2014 开发版。
失败并显示以下日志:
#Fields: event,computer,operator,source,sourceid,executionid,starttime,endtime,datacode,databytes,message
OnInformation,PAPERLESS-PRIME,NT AUTHORITY\NETWORK SERVICE,PAPERLESS-PRIME_PAPERLESS-PRIME_SQLEXPRESS_Transfer Objects Task,{F858F211-3783-40F8-9C7A-B477576706D4},{AB42BFE8-D674-4E86-ACEA-FA89BFF7E8BE},8/8/2016 11:40:52 AM,8/8/2016 11:40:52 AM,0,0x,Transferring database callmanager_pwc from PAPERLESS-PRIME server as callmanager_pwc to PAPERLESS-PRIME\SQLEXPRESS server
OnInformation,PAPERLESS-PRIME,NT AUTHORITY\NETWORK SERVICE,CDW_PAPERLESS-PRIME_PAPERLESS-PRIME_SQLEXPRESS_2,{2BE0FC74-D66D-4AFE-895F-B0CC80E7C848},{AB42BFE8-D674-4E86-ACEA-FA89BFF7E8BE},8/8/2016 11:40:52 AM,8/8/2016 11:40:52 AM,0,0x,Transferring database callmanager_pwc from PAPERLESS-PRIME server as callmanager_pwc to PAPERLESS-PRIME\SQLEXPRESS server
OnInformation,PAPERLESS-PRIME,NT AUTHORITY\NETWORK SERVICE,PAPERLESS-PRIME_PAPERLESS-PRIME_SQLEXPRESS_Transfer Objects Task,{F858F211-3783-40F8-9C7A-B477576706D4},{AB42BFE8-D674-4E86-ACEA-FA89BFF7E8BE},8/8/2016 11:40:52 AM,8/8/2016 11:40:52 AM,0,0x,Added data file callmanager in path C:\SQLDB14\callmanager_pwc.mdf to file group [PRIMARY]
OnInformation,PAPERLESS-PRIME,NT AUTHORITY\NETWORK SERVICE,CDW_PAPERLESS-PRIME_PAPERLESS-PRIME_SQLEXPRESS_2,{2BE0FC74-D66D-4AFE-895F-B0CC80E7C848},{AB42BFE8-D674-4E86-ACEA-FA89BFF7E8BE},8/8/2016 11:40:52 AM,8/8/2016 11:40:52 AM,0,0x,Added data file callmanager in path C:\SQLDB14\callmanager_pwc.mdf to file group [PRIMARY]
OnInformation,PAPERLESS-PRIME,NT AUTHORITY\NETWORK SERVICE,PAPERLESS-PRIME_PAPERLESS-PRIME_SQLEXPRESS_Transfer Objects Task,{F858F211-3783-40F8-9C7A-B477576706D4},{AB42BFE8-D674-4E86-ACEA-FA89BFF7E8BE},8/8/2016 11:40:52 AM,8/8/2016 11:40:52 AM,0,0x,Added log file callmanager_log in path C:\SQLDB14\callmanager_pwc.ldf
OnInformation,PAPERLESS-PRIME,NT AUTHORITY\NETWORK SERVICE,CDW_PAPERLESS-PRIME_PAPERLESS-PRIME_SQLEXPRESS_2,{2BE0FC74-D66D-4AFE-895F-B0CC80E7C848},{AB42BFE8-D674-4E86-ACEA-FA89BFF7E8BE},8/8/2016 11:40:52 AM,8/8/2016 11:40:52 AM,0,0x,Added log file callmanager_log in path C:\SQLDB14\callmanager_pwc.ldf
OnInformation,PAPERLESS-PRIME,NT AUTHORITY\NETWORK SERVICE,PAPERLESS-PRIME_PAPERLESS-PRIME_SQLEXPRESS_Transfer Objects Task,{F858F211-3783-40F8-9C7A-B477576706D4},{AB42BFE8-D674-4E86-ACEA-FA89BFF7E8BE},8/8/2016 11:40:52 AM,8/8/2016 11:40:52 AM,0,0x,Transferring data to database callmanager_pwc from callmanager_pwc
OnInformation,PAPERLESS-PRIME,NT AUTHORITY\NETWORK SERVICE,CDW_PAPERLESS-PRIME_PAPERLESS-PRIME_SQLEXPRESS_2,{2BE0FC74-D66D-4AFE-895F-B0CC80E7C848},{AB42BFE8-D674-4E86-ACEA-FA89BFF7E8BE},8/8/2016 11:40:52 AM,8/8/2016 11:40:52 AM,0,0x,Transferring data to database callmanager_pwc from callmanager_pwc
OnError,PAPERLESS-PRIME,NT AUTHORITY\NETWORK SERVICE,PAPERLESS-PRIME_PAPERLESS-PRIME_SQLEXPRESS_Transfer Objects Task,{F858F211-3783-40F8-9C7A-B477576706D4},{AB42BFE8-D674-4E86-ACEA-FA89BFF7E8BE},8/8/2016 11:40:54 AM,8/8/2016 11:40:54 AM,0,0x,Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
StackTrace: at System.Collections.BitArray.Set(Int32 index, Boolean value)
at Microsoft.SqlServer.Management.Smo.PermissionWorker.GetPermissionSetBase(PermissionEnumKind kind, Int32 i)
at Microsoft.SqlServer.Management.Smo.SqlSmoObject.GetPermissionsFromCache(PermissionEnumKind kind)
at Microsoft.SqlServer.Management.Smo.SqlSmoObject.AddScriptPermissions(StringCollection sc, PermissionEnumKind kind, ScriptingPreferences sp)
at Microsoft.SqlServer.Management.Smo.ScriptMaker.ScriptCreateSpecialUrn(Urn urn, ScriptingPreferences sp, ObjectScriptingType& scriptType)
at Microsoft.SqlServer.Management.Smo.ScriptMaker.ScriptCreate(Urn urn, ScriptingPreferences sp, ObjectScriptingType& scriptType)
at Microsoft.SqlServer.Management.Smo.ScriptMaker.ScriptCreateObjects(IEnumerable`1 urns)
at Microsoft.SqlServer.Management.Smo.ScriptMaker.ScriptUrns(List`1 orderedUrns)
at Microsoft.SqlServer.Management.Smo.ScriptMaker.DiscoverOrderScript(IEnumerable`1 urns)
at Microsoft.SqlServer.Management.Smo.ScriptMaker.ScriptWorker(List`1 urns, ISmoScriptWriter writer)
at Microsoft.SqlServer.Management.Smo.DataTransferBase.GetScriptLoadedTransferWriter()
at Microsoft.SqlServer.Management.Smo.Transfer.TransferData()
at Microsoft.SqlServer.Dts.Tasks.TransferObjectsTask.TransferObjectsTask.TransferDatabasesUsingSMOTransfer()
OnError,PAPERLESS-PRIME,NT AUTHORITY\NETWORK SERVICE,CDW_PAPERLESS-PRIME_PAPERLESS-PRIME_SQLEXPRESS_2,{2BE0FC74-D66D-4AFE-895F-B0CC80E7C848},{AB42BFE8-D674-4E86-ACEA-FA89BFF7E8BE},8/8/2016 11:40:54 AM,8/8/2016 11:40:54 AM,0,0x,Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
StackTrace: at System.Collections.BitArray.Set(Int32 index, Boolean value)
at Microsoft.SqlServer.Management.Smo.PermissionWorker.GetPermissionSetBase(PermissionEnumKind kind, Int32 i)
at Microsoft.SqlServer.Management.Smo.SqlSmoObject.GetPermissionsFromCache(PermissionEnumKind kind)
at Microsoft.SqlServer.Management.Smo.SqlSmoObject.AddScriptPermissions(StringCollection sc, PermissionEnumKind kind, ScriptingPreferences sp)
at Microsoft.SqlServer.Management.Smo.ScriptMaker.ScriptCreateSpecialUrn(Urn urn, ScriptingPreferences sp, ObjectScriptingType& scriptType)
at Microsoft.SqlServer.Management.Smo.ScriptMaker.ScriptCreate(Urn urn, ScriptingPreferences sp, ObjectScriptingType& scriptType)
at Microsoft.SqlServer.Management.Smo.ScriptMaker.ScriptCreateObjects(IEnumerable`1 urns)
at Microsoft.SqlServer.Management.Smo.ScriptMaker.ScriptUrns(List`1 orderedUrns)
at Microsoft.SqlServer.Management.Smo.ScriptMaker.DiscoverOrderScript(IEnumerable`1 urns)
at Microsoft.SqlServer.Management.Smo.ScriptMaker.ScriptWorker(List`1 urns, ISmoScriptWriter writer)
at Microsoft.SqlServer.Management.Smo.DataTransferBase.GetScriptLoadedTransferWriter()
at Microsoft.SqlServer.Management.Smo.Transfer.TransferData()
at Microsoft.SqlServer.Dts.Tasks.TransferObjectsTask.TransferObjectsTask.TransferDatabasesUsingSMOTransfer()
OnProgress,PAPERLESS-PRIME,NT AUTHORITY\NETWORK SERVICE,PAPERLESS-PRIME_PAPERLESS-PRIME_SQLEXPRESS_Transfer Objects Task,{F858F211-3783-40F8-9C7A-B477576706D4},{AB42BFE8-D674-4E86-ACEA-FA89BFF7E8BE},8/8/2016 11:40:55 AM,8/8/2016 11:40:55 AM,0,0x,Database transfer failed for 1 database(s).
请问这是产品的问题,还是我做错了什么?
这里有点晚了,但希望这对其他人有所帮助。我收到了类似的问题,并将两台服务器都更新到最新的 CU 为我修复了它。
我知道实现此目标的唯一正确方法是从较高版本的 SQL 服务器生成脚本,并在较低版本的 运行 上生成脚本。为此,请按照以下步骤操作:
- 打开 SQL Server Management Studio
- 右键单击您正在使用的数据库。
- 选择任务 > 生成脚本
- 您将看到一个向导屏幕,在介绍中您可以单击下一步。
- 选择是对整个数据库和对象编写脚本还是对它们单独select。我喜欢把它作为第一个选项,一切。点击下一步
- 在输出类型中,选择将脚本保存到特定位置
- 保存到文件
- 点击高级
- 服务器版本脚本
- 选择你要的版本,我的是2012
- 要编写脚本的数据类型 - 架构和数据
- 保持其他设置不变。
- 点击确定
- 要生成的文件 - 单个文件
- 文件名 - 为脚本命名,扩展名为 .sql
- 另存为 Unicode 文本
- 点击下一步
- 使用加号打开选项
- 检查摘要中的设置是否全部正常 - 您主要查看要编写脚本的版本和数据类型
- 点击下一步
- 等待 运行,如果成功,您应该会一直看到绿色的勾号。
- 点击完成
- 然后转到您保存脚本的位置。
- 打开脚本
- 确保 .mdf 和 log.ldf 文件的文件路径正确。
- 运行 脚本
- 您可能会遇到如下错误: 无法添加主体 'CodeShare',因为它不存在或您没有权限 忽略这一点很好。它从来没有给我带来问题。
步骤取自this article,帮了我很多次。
如果您的脚本包含大量数据,您可以使用 CMD 加载它:
- 打开命令提示符 window。
- 在命令提示符 window 中,键入:
sqlcmd -S myServer\instanceName -i C:\myScript.sql
- 按 ENTER。
步骤2中的路径当然只是简单示例。
另一种方法是只编写没有数据的数据库模式脚本,并在具有较低版本 SQL 服务器的目标服务器上重新创建它。接下来,您可以使用 SSMS 连接到两个实例并将数据从一个实例复制到另一个实例,但是如果您定义了表之间的关系,则必须记住正确的复制顺序。在这种情况下,删除关系并重新创建它们可能是一个很好的策略(请记住,您在生成的脚本中获得了它们)。 这样做的另一个陷阱是主 key/identity 列 - 默认设置阻止将数据插入此类列,但您可以实现此 运行ning 命令:
SET IDENTITY_INSERT dbo.YourTableName ON;
插入成功后你还应该运行:
SET IDENTITY_INSERT dbo.YourTableName OFF;
希望本手册对您有所帮助。