Update if ID exists

  • I have a Table X

    FileID CallID CloseddateTime

    1 0001 NULL

    2 0003 NULL

    3 0003 NULL

    I have to update the ClosedDatetime field

    FileID CallID CloseddateTime

    1 0001 4/18/2011

    2 0003 NULL

    3 0003 NULL

    If the previous FileID contains the CallID but the new fileID loaded doesnot contain that CallId then update ClosedDatetime field to getdate()

    I am doing something like this

    UPDATE dbo.X

    SET

    ClosedDateTime = GETDATE()

    WHERE CallID IN (SELECT CallID FROM dbo.X WHERE FileID = (SELECT MAX(FileID) -1 FROM dbo.X))

    AND CallID NOT IN (SELECT MAX(FileID) FROM dbo.X)

    But this is updating all the callids.

    Please Help.

  • Can anybody help me ?

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

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