Query to create Jobs based upon Job

Use this query to create Jobs based upon a single Job:

Insert Into [Job] ([DBId], [Id], [Number], [ClientId], [JobTypeId], [DivisionId], [Description], [Actif], [Archive],
[JobServiceTRRestriction], [StartDate], [EndDate], [Chargeable], [Status], [TRLockType], [FileHolderEmployeeId],
[ReferenceYear], [SupplierBudgetAmount], [JobCategoryId], [StrategyId])
Select [Client].[DBId] as [ResDBId],
ROW_NUMBER() OVER(ORDER BY left(case when [Company].[Name] Is Null then [Person].[Name] else [Company].[Name] end,63)) + nnnn AS [ResId],
left(case when [Company].[Name] Is Null then [Person].[Name] else [Company].[Name] end,63) + ' - Advisory' as [ResNumber],
[Client].[Id] as [ResClientId],
[Job].[JobTypeId] as [ResJobTypeId],
[Job].[DivisionId] as [ResDivisionId],
[Job].[Description] as [ResDescription],
[Job].[Actif] as [ResActif],
[Job].[Archive] as [ResArchive],
[Job].[JobServiceTRRestriction] as [JobServiceTRRestriction],
[Job].[StartDate] as [StartDate],
[Job].[EndDate] as [EndDate],
[Job].[Chargeable] as [Chargeable],
[Job].[Status] as [Status],
[Job].[TRLockType] as [TRLockType],
[Job].[FileHolderEmployeeId] as [FileHolderEmployeeId],
[Job].[ReferenceYear] as [ReferenceYear],
[Job].[SupplierBudgetAmount] as [SupplierBudgetAmount],
[Job].[JobCategoryId] as [JobCategoryId],
[Job].[StrategyId] as [StrategyId]
from (([Client] LEFT JOIN [Company]
ON ([Client].[CompanyId] = [Company].[Id] and [Client].[DBId] = [Company].[DBId]))
LEFT JOIN [Person]
ON ([Client].[PersonId] = [Person].[Id] and [Client].[DBId] = [Person].[DBId])), [Job]
where [Client].[DBId] = 1 and not [Client].[Id] = xxxxx
and [Job].[DBId] = yyyyy and [Job].[Id] = zzzzz and [Client].[EndDate] = '30/12/1899'
order by left(case when [Company].[Name] Is Null then [Person].[Name] else [Company].[Name] end,63)