Query Causing Error 1222

  • Hi Experts,

    Our SQL Server getting lock timeout error 1222 when running the below given query

    CREATE PROC [devidp].[AD_DelRKN]

    (

    @RKNID int

    )

    AS

    SET NOCOUNT ON;

    BEGIN TRANSACTION DelRKN

    DELETE FROM RKN_address WHERE RKN_id=@RKNId

    DELETE FROM RKN_contact_media WHERE RKN_id=@RKNId

    DELETE FROM person_RKN WHERE RKN_id=@RKNId

    DELETE FROM RKN WHERE RKN_id=@RKNId

    SELECT 1

    COMMIT TRANSACTION DelRKN

    IF @@TRANCOUNT=0

    BEGIN

    ROLLBACK TRANSACTION DelRKN

    SELECT 0

    END

    SET NOCOUNT OFF;

    Please help me in resolving this issue.

    TIA

  • are there any triggers on those tables?

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • Thanks for the reply Christopher,

    The tables dont have any triggers. Is there any problem with the logic or order of execution in that query?

  • What's blocking the query?

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • first run a portion then add some extent and loop it.

    Thanks

  • How many rows are those deletes going to affect?

    You're running that in a transaction, but there's no error handling at all. The commit is always going to fire, regardless of any errors that the deletes encounter. Is that what you want?

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply