• --This code affects all the records inserted into books with the same uniqueidentifier

    CREATE TRIGGER tr1 ON Books AFTER INSERT AS

    UPDATE Books

    SET batchUID = NEWID() --batchUID being a uniqueidentifier field

    FROM Books

    INNER JOIN Inserted

    ON Inserted.bookCode = Books.bookCode

    GO