Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SSIS and Import/Export (2005)
 Inserting data into composite primary key

Author  Topic 

aisha09
Starting Member

6 Posts

Posted - 2010-07-22 : 14:01:39
Table vendor
vendorid(primarykey) vendorname
1 target
2 med
3 mdi
4 cashwise
5 walmart

Table client
clientid(primarykey) clientname
1 A

Table clientvendor
clientid vendorid (composite primarykey)
1 1
1 2
1 3
1 4
1 5
Rule: 1 client has many vendors and many vendors may belong to many clients.

I have to insert the vendorid and the clientid from the client and vendor table into clientvendor junction table. Since I have just one client; I was able to insert the records into the junction table with the help of a cross join.

If I have another client record into the client table inserted as follows; and vendorids 2 and 3 also belong to client B;

clientid(primarykey) clientname
1 A
2 B

Could someone please let me know how would I get the following result; I must also note that I will be dealing with thousands of common vendors data between two or three clients. Is it possible with SSIS?

Table clientvendor
clientid vendorid (composite primarykey)
1 1
1 2
1 3
1 4
1 5
2 2
2 3
   

- Advertisement -