Thanks. It worked.to simplify here an sqlCREATE TABLE #table1(PID INT,SID INT)INSERT INTO #table1 VALUES (1,1)INSERT INTO #table1 VALUES (1,2)INSERT INTO #table1 VALUES (1,3)INSERT INTO #table1 VALUES (1,4)CREATE TABLE #table2(PID INT,SID INT,PlDate datetime,Col1 INT)INSERT INTO #table2 VALUES (1,1,getdate(),1)INSERT INTO #table2 VALUES (1,2,getdate(),1)select PID = t1.PID, SID = t1.SID, t2.PlDatefrom #table1 t1full outer join #table2 t2on t1.PID = t2.PIDand t1.SID = t2.SIDDROP TABLE #table1DROP TABLE #table2