I am running a SQL query to update the column,
ScheduleID = 123222
FROM Price sip
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
)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.