MadIce
asked on
Select Query to Insert slows process
I have a Select query that runs within a second. When I change to an Insert query, runs longer than 12 minutes. here is the code:
Its the second insert query that is running slow. If I changed to select, no problem. why is this an issue?
Using SQL Server 2008 R2, SSMS
declare @ADC table (
Lot varchar(20),
Rev varchar(5)
)
declare @ADC1 table (
Lot varchar(20),
ComponentLot varchar(30))
insert into @ADC
SELECT EADC.LOT, ADC.REV
FROM ITEM_ID AS EADC INNER JOIN
DATA_CARDS AS ADC ON EADC.ADC_ID = ADC.ADC_ID
WHERE (ADC.NUM = '9246248')
insert into @ADC1
SELECT distinct EADC.LOT, CADC.LOT_NUM AS ComponentLot
FROM ITEM_ID AS EADC INNER JOIN
DATA_CARDS AS CADC ON EADC.ADC_ID = CADC.ADC_ID INNER JOIN
Noun N ON EADC.NounId = N.NounId
where CADC.LOT in (Select Lot from @ADC) and N.NOUN like '%BODY%ASSY%'
Its the second insert query that is running slow. If I changed to select, no problem. why is this an issue?
Using SQL Server 2008 R2, SSMS
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you for the answer and the time.