--Insert the values from the selected payroll into the same table
INSERT INTO WF_MilestoneRule --Id column automatically generated
(ParentId
,MilestoneType
,MilestoneName
,MilestoneDescription
,RuleTypeId
,RuleValueId
,RuleValue
,Time
,AdminFolderId
,ExternallyVisible
,MilestoneCreatedById) -- Id of the column that has been copied from
SELECT
(SELECT t2.Id FROM WF_MilestoneRule t2 WHERE t1.MilestoneCreatedById = t2.ParentId)
,MilestoneType
,MilestoneName
,MilestoneDescription
,RuleTypeId
,RuleValueId
,RuleValue
,Time
,@FolderId
,ExternallyVisible
,Id
FROM WF_MilestoneRule t1
WHERE t1.AdminFolderId = @AdminFolderId