Have following code that I need to modify and only insert into #TempTable1 if BatchGuid does not exist. Thank you.begininsert into #TempTable1 ( BatchGuid, BatchName, ReportDate, JobNumber, ReportStatus, ReportOwner, ApprovalLevel )select distinct(Event.BatchGuid) as BatchGuid, Batch.Name as BatchName, Batch.ReportDate as ReportDate, Job.CompanyJobId as JobNumber, EventStatusType.Name as ReportStatus, Account.UserName as ReportOwner, EventApprovalLevel.Name as ApprovalLevelfrom [VGIWPSQL2].goLabor30.dbo.event inner join [VGIWPSQL2].goLabor30.dbo.Batch on Batch.BatchGuid = Event.BatchGuid inner join [VGIWPSQL2].goLabor30.dbo.Job on Job.JobGuid = Event.JobGuid inner join [VGIWPSQL2].goLabor30.dbo.EventStatusType on EventStatusType.EventStatusTypeGuid = Event.EventStatus inner join [VGIWPSQL2].goLabor30.dbo.Account on Account.AccountGuid = Batch.AccountGuid inner join [VGIWPSQL2].goLabor30.dbo.EventApprovalLevel on EventApprovalLevel.EventApprovalLevelGuid = Event.EventApprovalLevelGuidwhere (@Owner IS Null or Account.Username = @Owner or Account.Username like replace(@Owner,'*','%')) and (@DateFrom IS Null OR Batch.Reportdate >= @DateFrom)and (@DateTo IS Null OR Batch.ReportDate <= @DateTo) and (@Job IS Null or Job.CompanyJobId = @Job or Job.CompanyJobId like replace(@Job,'*','%')) and (EventStatusType.Name = @StatusSelect3) and (EventApprovalLevel.Name = @ApprovalLevel1 or EventApprovalLevel.Name = @ApprovalLevel2) order by Batch.NameSET @RetValue = '0'end