• It didn't occur to me to verify the datatypes were the same, good point. Unfortunately it didn't help this time as the datatype is int.

    I didn't design the database, I just need to clean it up when something happens in a customer installation.

    The archiveID field will have a number of 1, 2, 3, 4, etc, in increasing order with no theoretical max, depending on how long the customer is using the system with a new set of archives added every week or two.

    I did some research and learned enough about triggers to be fairly confident that there are none associated with archiveID in any of the tables I am working with.

    There are several more tables involved in this. The first time I used it I did not create the variable, I simply had the value at the end of each line and it worked fine. The problem came up when I tried to use a variable so I would only have to edit the one line each time I used it.