• This is just a guess based on what you posted.

    else

    BEGIN

    SELECT @ID1 = NULL,

    @ID2 = NULL

    select @ID1=ID from [CBH] where [SID] = 2

    select @ID2=ID from [PBH] where [SID] = 2

    IF @ID1 IS NOT NULL

    INSERT into dbo.Logtable

    (

    AdditionalInfo

    )

    values('Another Process with ID:'+CAST(@ID1 AS varchar(20))+'is currently in use')

    IF @ID2 IS NOT NULL

    INSERT into dbo.Logtable

    (

    AdditionalInfo

    )

    values('Another Process with ID:'+CAST(@ID2 AS varchar(20))+'is currently in use')

    END

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2