目标表如下所示:
源表如下所示:
客户
CustomerId FirstName LastName电子邮件地址1地址2城市邮编
目标中的人员表是一个基表(稍后将由新的客户表继承)。所以我试图从一个表中导出一行并在目标中填充3个表。
我设法按照以下方式执行此操作:
此软件包的屏幕截图如下。
这种方法的最大问题是OLE DB Command任务是逐行插入的,它使整个包非常慢。是否有可能实现相同的目标,但使用快速负载?
我能够使用OLE DB Command任务调用存储过程然后
答案 0 :(得分:0)
我认为你不需要SSIS。 您可以使用INSERT的OUTPUT子句将所有身份密钥返回到临时表
让我们尝试重现你的场景......
set nocount on
go
create table Customer (CustomerId int, CustomerName varchar(100) null, Address1 varchar(100) null, Address2 varchar(100) )
create table [Person] (PersonId int identity, PersonName varchar(100) null)
create table [Address] (AddressId int identity, AddressLine varchar(100) null)
create table [PersonAddress] (AddressId int, PersonId int )
go
-- create some data...
insert into Customer (CustomerId) values ( 1000000 + convert(int, RAND() * 1000000) )
go 1000
update Customer
set CustomerName = 'CustomerName ' + convert(varchar, CustomerId),
Address1 = 'Address1 ' + convert(varchar, CustomerId),
Address2 = 'Address2 ' + convert(varchar, CustomerId)
go
declare @identities_Person table ([rownumber] int identity, id int)
declare @identities_Address table ([rownumber] int identity, id int)
insert into Person (PersonName)
output inserted.PersonId into @identities_Person
select
c.CustomerName
from Customer c
order by c.CustomerId
insert into [Address] (AddressLine)
output inserted.AddressId into @identities_Address
select
c.Address1
from Customer c
order by c.CustomerId
insert into [PersonAddress] (PersonId, AddressId)
select p.id, a.id
from @identities_Address a
inner join @identities_Person p on p.rownumber = a.rownumber
select *
from PersonAddress pa
inner join [Address] a on a.AddressId = pa.AddressId
inner join [Person] p on p.PersonId = pa.PersonId