且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从一个数据库表复制到另一个现有表

更新时间:2023-02-03 23:03:19

嗨试试这个..





SET IDENTITY_INSERT table1 ON

插入表1

select * from table2





this错误即将到来,因为您的表中有您从其他人插入数据的标识列。
hi try this..


SET IDENTITY_INSERT table1 ON
Insert into table1
select * from table2


this error is coming because you have identity column in your table inwhich you are inserting data from other.


试试这个:首先在表1中将标识列设置为false

然后运行脚本。

或发布两个表的完整列。只有一个人可以为您提供解决方案



try this: first of set the identity column to "false" in the table1
and then run the script.
or post the complete columns of both tables. only a person can you a solution

Insert into db1.dbo.table1
select * from db2.dbo.table2


您应该检查:

MSDN:批量导入数据时保留标识值(SQL Server) [ ^ ]

试试这个:

You should check with this:
MSDN : Keep Identity Values When Bulk Importing Data (SQL Server)[^]
Try this:
SET IDENTITY_INSERT Db1.dbo.[B] ON
insert into db1.dbo.[B]
select * from db2.dbo.[A] where reqid = 201
SET IDENTITY_INSERT db1.dbo.[B] OFF







- Amit