I have below 2 procs that runs weekly @ 3am via SQL agent job. So both procs start executing at the same time.
The proc "dbo.Proc1" fails in a few seconds: "Transaction (Process ID 46) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction." However proc "dbo.Proc2" runs successfully.
Can anyone please help me solve this deadlock issue? Thanks.
ALTER PROCEDURE dbo.Proc1
AS
BEGIN
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
/* SELECT statements here that take ~20 minutes to return data */
/* The base table here is dbo.Table1, which is a huge table */
END
ALTER PROCEDURE dbo.Proc2
AS
BEGIN
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
/* SELECT statements here that take ~20 minutes to return data */
/* The base table here is dbo.Table1, which is a huge table */
END
I prefer dirty read here because it's kind of summary report and don't need to be up to date. When these run @ 3am, nothing else is happening - i.e. Nobody accessing the same db...It's just internal app.
I'm confused why it causes deadlock even if it's dirty read!