Your procedure will have to do a self-join from itself to a derived table of itself that is grouped by the primary key you are describing. In order to accomplish this, you will more than likely need to dump the tables to keyless temp tables that have IDENTITY keys, so that you can do an INNER JOIN on the IDENTITY when making the final insert.
--
For instance, the procedure would pull the three tables into 3 temp tables with a PRIMARY KEY defined on an IDENTITY field. Once populated, you would do some like this:
-- Example temp table:
CREATE TABLE #Temp1
(
ID INT IDENTITY(1,1) NOT NULL PRIMARY KEY
, MyPKField1 CHAR(10) NOT NULL
, MyPKField2 CHAR(10) NOT NULL
-- , OtherFields...
)
-- SELECT FROM the Main Table, Joining to a subset of itself
-- with only unique keys.
SELECT
a.MyPKField1
, a.MyPKField2
--, a.OtherFields...
FROM #Temp1 a
INNER JOIN
(
SELECT
MIN(b.ID) AS FirstID
, b.MyPKField1
, b.MyPKField2
FROM #Temp1 b
GROUP BY
b.MyPKField1
, b.MyPKField2
) AS c
ON a.ID = c.FirstID
HTH,
Jay