[英]SQL Server 2008 R2 Data Export Problems
I am trying to export data from my production DB to my development DB but I am getting this error: 我正在尝试将数据从我的生产数据库导出到我的开发数据库但是我收到此错误:
Messages Error 0xc0202049: Data Flow Task 1: Failure inserting into the read-only column "id". 消息错误0xc0202049:数据流任务1:未能插入只读列“id”。 (SQL Server Import and Export Wizard) (SQL Server导入和导出向导)
Is there a way to check which column is that because I have 20 tables that all of them use the column name id
or at least get a better error report? 有没有办法检查哪一列是因为我有20个表,所有这些表都使用列名id
或至少得到一个更好的错误报告?
Just click on Edit mappings
when you choose tables to import from and to. 选择要从中导入的表时,只需单击“ Edit mappings
即可。 and check on the Enable identity insert
checkbox. 并选中Enable identity insert
复选框。 And you should do that for each choosen table. 你应该为每个选择的表做到这一点。 Then you can complete your import. 然后,您可以完成导入。 It was helped me in the same situation. 在同样的情况下帮助了我。
If the column ID is an identity column, it's likely set up to generate automatically when a row is inserted, and is not able to be directly written to. 如果列ID是标识列,则可能设置为在插入行时自动生成,并且无法直接写入。
To preserve linking from the production environment to the test, use: 要保留从生产环境到测试的链接,请使用:
SET Identity_Insert <TableName> ON
To allow you to write identity values. 允许您编写标识值。
All I had to do was: 我所要做的就是:
If anyone knows a different (faster) way of doing this please share 如果有人知道不同(更快)的方式,请分享
听起来好像你可能试图将值插入已声明为IDENTITY字段的列中。
Well, the answer is a bit late but I'm posting it anyway for the sake of providing to community. 嗯,答案有点晚,但我还是为了向社区提供而发布它。
I assume that you are trying to copy tables (not partial data). 我假设您正在尝试复制表(而不是部分数据)。 My answer is based on this assumption. 我的答案是基于这个假设。
Select tables that you want to be completely copied to the destination. 选择要完全复制到目标的表。 And click on 'edit mappings'. 然后单击“编辑映射”。 Here you may 'enable identity insert'. 在这里你可以'启用身份插入'。 You will also have other options so check the screen before pressing OK. 您还可以选择其他选项,然后在按OK之前检查屏幕。
If you do not use an express edition of SSMS here you may create an SSIS package to create jobs and to automatize this process in the future. 如果您不在此处使用SSMS的快速版本,则可以创建SSIS包以创建作业并在将来自动化此过程。 You may check 'run immediately' and follow the screen about how it goes with all the warnings and errors. 您可以选中“立即运行”并按照屏幕显示所有警告和错误的情况。 Hopefully you will get none. 希望你不会得到任何东西。 Good luck! 祝好运!
Tested with:
(
Microsoft SQL Server 2008 R2 (SP1) - 10.50.2500.0 (Intel X86)
Jun 17 2011 00:57:23
Copyright (c) Microsoft Corporation
Enterprise Edition on Windows NT 5.2 <X86> (Build 3790: Service Pack 2)
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.