Hi there,<br>I am trying to create a trigger that emulates the autonumber field in Microsoft Access.<br>What I want to do is that every time when I insert a new row(record) in the "holidays" table, the field "id" for the newest row becomes the highest in the table.<br>The code below works great if there is only one row inserted<br><br>"CREATE TRIGGER NOVAPHL.TR_HOLIDAYS_5 AFTER INSERT ON NOVAPHL.HOLIDAYS REFERENCING NEW AS nr FOR EACH ROW MODE DB2SQL WHEN ( ID IS NULL) BEGIN ATOMIC UPDATE HOLIDAYS SET ID = CASE WHEN ((SELECT MAX(ID) FROM HOLIDAYS) IS NULL) THEN 1 ELSE (SELECT MAX(ID) FROM HOLIDAYS) + 1 END WHERE ID IS NULL; END"<br><br>, but if I have more than 1 rows inserted with <br><br>"INSERT INTO holidays ( hdate, description, callcenterid )<br>SELECT masterholidays.hdate, masterholidays.name,22<br>FROM masterholidays WHERE masterholidays.ID IN (1,2)"<br><br>then all the new "id" fields have the same value which is not what I intended to do(I want unique numbers).<br><br><br>Thank you for your help,<br><br>Kyle Tinjala<br>Nova CTI<br><A HREF="mailto:support@novacti.com">support@novacti.com</A>