I have the following insert trigger which seems to work okay when only one row is inserted. When multiple rows are inserted then it fails. Would you please point out where I am going wrong here?
Thanks in advance for any help.
CREATE TRIGGER [dt_JobInsert] ON [dbo].[JobTable]
DECLARE @TaskMasterID as int
DECLARE @JobID as varchar(50)
SELECT @JobID = (SELECT JOB_ID FROM Inserted)
SELECT JOB_ID, GETDATE(), 'New',DISTRICT_CODE
SELECT @TaskMasterID =
(SELECT TaskMasterID FROM TaskMaster WHERE TaskMaster.JobNumber = @JobID)
UPDATE TaskMaster SET TaskMaster.OrigTaskMasterID = @TaskMasterID WHERE TaskMaster.TaskMasterID = @TaskMasterID