2

我正在从将 BillingAddress 与送货地址相结合的模式中重构我的数据库的用户对象:

[BillingFirstName] [nvarchar](50) NOT NULL,
[BillinglastName] [nvarchar](50) NOT NULL,
[BillingAddress] [nvarchar](100) NOT NULL,
[BillingCity] [nvarchar](100) NOT NULL,
[BillingZip] [varchar](16) NOT NULL,
[BillingState] [nvarchar](2) NOT NULL,
[shippingFirstName] [nvarchar](50) NULL,
[shippingLastName] [nvarchar](50) NULL,
[shippingAddress] [nvarchar](100) NULL,
[shippingCity] [nvarchar](100) NULL,
[shippingState] [nvarchar](2) NULL,
[shippingZip] [nvarchar](20) NULL,
[shippingPhone] [nvarchar](30) NULL,

重构为一个用于 User 的表和一个用于由外键 Users.ID => Addresses.idUser 绑定的地址的单独表

    CREATE TABLE [dbo].[Addresses](
[Id] [int] IDENTITY(1,1) NOT NULL,
[Type] [nchar](10) NOT NULL, // designates Billing or Shipping
[Formatted] [nchar](600) NOT NULL,
[Street] [nchar](100) NOT NULL,
[City] [nchar](100) NOT NULL,
[POBox] [nchar](50) NULL,
[Region] [nchar](50) NULL,
[PostalCode] [nchar](50) NULL,
[Country] [nchar](50) NULL,
[ExtendedAddress] [nchar](100) NULL,
[idUser] [int] NULL,

如何告诉 SSIS 将记录导入简化的用户对象,然后创建 2 个地址记录;一个带有运输信息,另一个带有帐单?

我想保留现有的 ID 密钥。

谢谢

4

1 回答 1

1
  1. Multicast your source data.
  2. Add a Derived Column component to each output stream. In your mind, designate one as the "Billing Address" stream and one as the "Shipping Address" stream.
  3. Add a new column named "Type", hardcoded to "Billing" and "Shipping", respectively.
  4. Add a destination component to each streams both pointing to your Address table.
  5. Map the appropriate columns in each stream (ie BillingCity to the City in the "billing address" stream, ShippingCountry to the Country in the "shipping address" stream, etc.)
于 2012-12-06T15:26:46.667 回答