could you please suggest me how do I improve below SQL code, I have observed using SQL profiler - XML reading operation is taking too much of time.
Kindly let me know how do I rewrite the below code, so that I can see improvement in the performance.
Here - edata is the XML Column
DECLARE @SFD TABLE ( etid BIGINT, eAmount DECIMAL(12, 2), eDate DATE) INSERT INTO @SFD
SELECT tr.etid,tr.edata.value('(EData/Amount)[1]', 'DECIMAL(12, 2)') eAmount,tr.edata.value('(EData/DrawDate)[1]','date') eDate
FROM dbo.erequest tr
WHERE tr.accountid = @AccountIdIN the above query - following lines are taking too much of time,
**tr.edata.value('(EData/Amount)[1]', 'DECIMAL(12, 2)') eAmount,tr.edata.value('(EData/DrawDate)[1]','date') eDate**
Kindly advise me , how do I rewrite the above lines in the main sql query so that I can see the performance improvement.
Kindly find the below query to populate the Table data:
Create table erequest
(
etid BIGINT,
edata XML,
accountid INT
)
INSERT INTO erequest (etid,edata,accountid) VALUES (2145124897,
'
ABCFDE
K6011
555.17
2022-05-18
USD
',10)
INSERT INTO erequest (etid,edata,accountid) VALUES (2145124897,
'
ABCFDE
K6011
555.17
2022-05-18
USD
',20)
INSERT INTO erequest (etid,edata,accountid) VALUES (2145124897,
'
ABCFDE
K6011
555.17
2022-05-18
USD
',30)
INSERT INTO erequest (etid,edata,accountid) VALUES (2145124897,
'
ABCFDE
K6011
555.17
2022-05-18
USD
',12)
INSERT INTO erequest (etid,edata,accountid) VALUES (2145124897,
'
ABCFDE
K6011
555.17
2022-05-18
USD
',16)
Guest UserRank #816 · 2.8K reputationPosted May 19, 2022, 7:51 AM EDT
Kumar AURank #3,821 · 387 reputationPosted May 19, 2022, 9:13 AM EDT
Thank you pritaeas for your response.
Are you trying to explain before i insert into @SFD temp table, First I need to write a seperate query to extarct Amount and Date and then put these 2 values in a variable and then insert into @SFD temp table
Guest UserRank #816 · 2.8K reputationPosted May 23, 2022, 7:39 AM EDT