• What do you mean by not functional?

    I am not sure you need the temp tables. Does this help?

    IF (@TC = 'BUY')

    BEGIN

    UPDATE....WHERE A.TransType = 'BUY'

    END

    IF (@TC = 'SELL')

    BEGIN

    UPDATE....WHERE A.TransType = 'SELL'

    END

    IF (@TC = 'ALL')

    BEGIN

    UPDATE....WHERE A.TransType IN ('BUY','SELL')

    END

    Before you start updating data please test with SELECT statements first to validate.