• The problem with the sp is that the value 'I' is being inserted into a field defined as char(1), so this sp would never work.

    Change 'I' to ''I'' and it should work. This same change should be made for the other transaction types also.

    IF (@cnti > @cntd)

    BEGIN

    set @DUI = ' ''I'' ' --should be set @DUI = 'I'

    SET @cmdFROM = ' FROM #ti d '

    END

    -- insert record into table modif

    insert into modif(tablenm, dml_type)

    select @tblname, @dui