I have two temporary table #CoreUtilizationForRole1 and #RoleID2Details. I want to insert values into a third temp table using these two temp table. Below are the table Structure of both the Temp table.
create table #CoreUtilizationForRole1(roleid int,SupervisorName varchar(50),ImmediateSupervisor varchar(50),UserECode varchar(50),UserName nvarchar(250),Designation varchar(250),TimeSpent float,ActivityName varchar(250))
create table #RoleID2Details(UserECode varchar(50),UserName nvarchar(250))
in #CoreUtilizationForRole1 table I had generated a report and stored in it. #RoleID2Details contains data as mentioned below in the query:-
insert into #RoleID2Details
select distinct Userecode,Username from #CoreUtilizationForRole1 where roleid=2
Now I want to loop through each records of #RoleID2Details and insert data into a third temp table while joining from #CoreUtilizationForRole1. AcTually I need data in a particular described format and due to that, this looping is required so that I insert data into third temp table as per my requirement and then using a simple select statement I will display it. Please help me to do this.