SQL脚本跨库批量导入数据

1.开启标识插入

2.insert select from 批量插入,注意SQL 语句带数据库名称

3.批量导入之后关闭标识插入

 

具体SQL脚本入校

SET IDENTITY_INSERT [A数据库名称].[dbo].[Delegations] ON; --关闭
INSERT INTO [A数据库名称].[dbo].[Delegations]
([Id], [UserName], [Realm], [Description])
SELECT [Id], [UserName], [Realm], [Description]
FROM [B数据库名称].[dbo].[Delegations]
SET IDENTITY_INSERT [A数据库名称].[dbo].[Delegations] OFF; --开启
GO

posted @ 2019-03-21 14:11  蜗牛行  阅读(443)  评论(0编辑  收藏  举报