Merging two tables and keeping the id unique

  • I have two tables A and B, as given below

    CREATE TABLE [dbo].[A](

    [CustomerKey] [int] IDENTITY(1,1) NOT NULL,

    [customerID] [int] NULL,

    [firstName] [varchar](50) NULL,

    [lastName] [varchar](50) NULL,

    [varchar](50) NULL,

    [username] [varchar](50) NULL,

    [password] [varchar](50) NUL

    ]

    CREATE TABLE [dbo].(

    [customerID] [int] NotNull,

    [firstName] [varchar](50) NULL,

    [lastName] [varchar](50) NULL,

    [varchar](50) NULL,

    [username] [varchar](50) NULL,

    [password] [varchar](50) NUL,

    [SSN][varchar](50) Null

    )

    I would like to insert from table B into table A, however since they were created across two channels the customer id's across would match(though they hold separate information for each matching record)

    For example

    A

    customer-id firstname lastname email

    1 Alan johnson ajoh@abc.com

    2 Brad James bjam@nbc.com

    3 Charles johannson c.johhanson@cbs.com

    4 Desmond flakes d.flake@msnbc.com

    B

    customer-id firstname lastname email

    1 peter johns pjoh@abc.com

    2 Brian Judd bjudd@nbc.com

    3 Charles johnson c.johnson@cbs.com

    4 Desmond fonseca d.fons@msnbc.com

    So i insert table b values into A, however i wanto keep the cust-id's to uniquely identify the record.

    Any ideas folks??

    Thanks

  • I think i would just merge and create a unique id with a reference id back to the old table in case i need to perform updates.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply