正如您在上面的屏幕截图中看到的,此查询提供了并行插入:
INSERT INTO #StateAllocationData WITH (TABLOCK)
(ProjectID,StateId,StateLineDescriptionId,PartnerID,Value)
SELECT @ProjectID as ProjectID,sld.StateId,sld.ID,TaxReturnPartnerNumber,0 as Value
FROM Meta.States S(NOLOCK)
LEFT JOIN Meta.StateAllocationLineDescriptions SLD(NOLOCK) ON S.StateId = SLD.StateId
join Ottp.PartnerData PD on ProjectID=@Projectid
WHERE SLD.isDeleted = 0 AND SLD.ID IS NOT NULL
但是,正如您在上面的屏幕截图中看到的那样,此查询不执行并行插入,我想知道为什么:
INSERT INTO #SAmt WITH (TABLOCK) (ProjectID,StateId,K1SummaryID,StateLineDescriptionId)
SELECT @ProjectID AS 'ProjectID',
S.StateId,
SLD.StateLineDescriptionId AS 'K1SummaryID',
SLD.ID AS 'StateLineDescriptionId'
FROM Meta.States S(NOLOCK)
LEFT JOIN Meta.StateAllocationLineDescriptions SLD(NOLOCK) ON S.StateId = SLD.StateId
WHERE --SLD.isK1Summary <> 0 and
SLD.isDeleted = 0
AND SLD.ID IS NOT NULL