• Hey everyone, I haven't posted in a while, so I thought I'd chime in on a good one like this. I've used alot of the suggestions in the past with varying results. It's really hard to design business rules with triggers when there are so many inputs and outputs. This is more and more apparent to me every day in the health industry.

    I got an idea reading through this discussion...I want to see what yall think about it

    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

    CREATE TRIGGER tr2 ON Books AFTER INSERT AS

    DECLARE @batchUID uniqueidentifier

    SET @batchUID = (SELECT TOP 1 @batchUID FROM Inserted)

    EXEC usp_Process @batchUID=@batchUID

    GO

    Of course this only works if a.) you can alter the table schema and b.) if you can alter stored procedures to handle optional parameters. The only other exceptions I can see if is the SP uses a non-batch API or you need to generate some type of customized ID field.