Pho3nix
The Legend
Hi all,
Working on a trigger but I can't get the ID row I'm inserting into. Any help would be appreciated.
Below is the code I'm using but it fails
The one above works but gives me 0. My google-fu is failing me so thought I'd ask here
Working on a trigger but I can't get the ID row I'm inserting into. Any help would be appreciated.
Below is the code I'm using but it fails
Code:
ALTER TRIGGER tr_PCompliance_Insert
ON P1
INSTEAD OF INSERT
AS
SET NOCOUNT ON
DECLARE
@P1d INT
SET @P1Id = (SELECT @@Identity)
INSERT INTO P2 (PId,RuleId,PeriodId,DataId,Data)
SELECT PD.PId,PD,RuleId,PD.PeriodId,@ProjectDataId,PD.Data
FROM
INSERTED PD
Code:
ALTER TRIGGER tr_PCompliance_Insert
ON P1
INSTEAD OF INSERT
AS
SET NOCOUNT ON
INSERT INTO P2 (PId,RuleId,PeriodId,DataId,Data)
SELECT PD.PId,PD,RuleId,PD.PeriodId,PD.Id,PD.Data
FROM
INSERTED PD
The one above works but gives me 0. My google-fu is failing me so thought I'd ask here