Is it possible to run multiple stored procedures within a transaction, and not violate my foreign key constraints?I have something like this:begin trandeclare @P1 intset @P1=0exec cor_UpsertPartnerNote @NoteID = @P1 output, @PostDate = N'10/16/2004 01:23:51 PM', @NoteText = N'A new note.', @PostedByUserID = N'1', @PartnerID = N'2'select @P1exec cor_UpdatePartnerNoteVisibility @NoteID = @P1, @Visibility = N'1'if (@@ERROR != 0) begin rollbackend else begin commitend
Whenever I try to run the above code, where the first proc inserts a new note, and returns the ID, I get the following message when the second proc is run:INSERT statement conflicted with COLUMN FOREIGN KEY constraint 'FK_cor_PartnerNoteVisibility_cor_PartnerNotes'. The conflict occurred in database 'junk', table 'cor_PartnerNotes', column 'NoteID'.The statement has been terminated.Is what I'm trying to do possible? Because basically I don't want any of the data inserted if the second proc fails.Thanks,Steve