Sean Lange (1/22/2014)
Dieselbf2 (1/22/2014)
Here is what I have so far. I am just trying to get the trigger to check the 2 frid that are on different tables before inserting the LgID into the [dbo].[ProposalProfitSplitWorksheet table:Am I on the right track
CREATE TRIGGER [UProposalProfitSplitWorksheet]
ON [dbo].[ProposalProfitSplitWorksheet]
FOR INSERT, UPDATE
AS
Declare @lfrid int
Declare @PFRID int
Select @lfrid = (Select L.FRID From Inserted As I Join logins As L On I.lgID = L.LgID)
Select @PFRID = (Select P.FRID From Inserted As I Join proposals As L On I.LgID = P.LgID)
Thanks
This might be somewhat ok with one MAJOR exception. It cannot handle multiple row inserts or updates.
Consider what value would be in @lfrid if someone ran the following update statement.
UPDATE ProposalProfitSplitWorksheet
set FRID = 9
where LgID in (1,2,3,4,5,6)
I will reiterate that trying to use a trigger for RI is the wrong methodology. My guess is that you want to create a function that you can use in a check constraint on the FRID column.
If I did it the way you are talking about, then every time my company got a new employee I would have to add the LgID and we have 39 FRID's.
Any help is appreciated