question

sankum avatar image
sankum asked

Update Query fail sometime

I am running a SQL query to update the column,

UPDATE sip

SET

ScheduleID = 123222

FROM Price sip

INNER JOIN

(

SELECT

sip.ItemPriceID

FROM Charge sipc

INNER JOI Price sip ON sip.ItemPriceID = sipc.ItemPriceID

INNER JOIN CtlCycle ctl ON ctl.BillingRunID = @BillingRunID

WHERE sipc.BillingRunID = @BillingRunID

AND CONVERT(DATE, BilledThruDate) >= CONVERT(DATE, DATEADD(DAY, -1, sipc.ItemPriceEndDate))

AND ISNULL(sip.OrderDate, '2000-01-01') <= ctl.OrdersThruDate

GROUP BY

sip.ItemPriceID

)AS t ON t.ItemPriceID = sip.ItemPriceID


It works fine in one environment and failed in another environment with the SQL timeout error.

I check the table charge having lots of null in columns ItemPriceEndDate, and if I add null check for column ItemPriceEndDate it works(AND sipc.ItemPriceEndDate is not null) fine.

The Question :

Why it works in one environment without any change and failed in another environment. Have the same amount of data in both environments.




query
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.