Hi vellirajI don’t know your scenario. May be its helpful for you.CREATE TABLE #temp1( Empid INT NULL, salary INT NULL, ID2 INT )GOCREATE TABLE #temp2( Empid INT NULL, phone INT NULL, ID2 INT )GOINSERT INTO #temp1(Empid,salary)SELECT 1, 5000 UNION ALLSELECT 1, 2000 UNION ALLSELECT 1, 3000INSERT INTO #temp2(Empid,phone)SELECT 1, 12345 UNION ALLSELECT 1 ,3456SELECT * FROM #temp1SELECT * FROM #temp2DECLARE @LOOPINDEX INTSET @LOOPINDEX = 0UPDATE T SET ID2 = @LOOPINDEX,@LOOPINDEX=@LOOPINDEX + 1FROM #temp1 TSET @LOOPINDEX = 0UPDATE T SET ID2 = @LOOPINDEX,@LOOPINDEX=@LOOPINDEX + 1FROM #temp2 TSELECT * FROM #temp1SELECT * FROM #temp2SELECT A.Empid, A.salary , B.phone FROM(SELECT * FROM #temp1 ) as ALEFT OUTER JOIN (SELECT * FROM #temp2 ) as BON A.ID2 = B.ID2DROP TABLE #temp1DROP TABLE #temp2
-------------------------R...