DeadLock Problems

  • I have a Stored Proc which handles a login, I'm select the MAX ID and returning that if its a new record or Inserting the new row if they dont exist.

    Currently I'm getting deadlock problems. The SP has the following IF statement within it:

    IF EXISTS(SELECT ID,Email,PW FROM tbl_TEST WHERE Email = @strEmail AND PW = @strPassword)

    BEGIN

    UPDATE tbl_TEST SET ApplicationType = @strApplicationType, TableType= @strTableType WHERE Email = @strEmail AND PW = @strPassword

    SELECT * FROM tbl_TEST WHERE Email = @strEmail AND PW = @strPassword

    SET @intReturnVal = 1

    RETURN

    END

    ELSE

    BEGIN

    SELECT @intMAXID = MAX(ID) + 1 FROM tbl_TEST

    INSERT INTO tbl_TEST (

    ID,

    PW,

    Email

    )

    VALUES(

    @intMAXID,

    @strPassword,

    @strEmail

    )

    SET @intReturnVal = 0

    SET @intNewMaxID = @intMAXID

    RETURN

    END

    The SQL queries all talk to the same table and it is in a flat table. Can you suggest how I update this code to aviod getting Deadlocks?? (Proper use of TRANS ??)

  • This was removed by the editor as SPAM

Viewing 2 posts - 1 through 1 (of 1 total)

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