Hi, a very basic trigger you could use a starting point is:
CREATE TRIGGER dbo.view_badge_upd ON dbo.view_badge
INSTEAD OF UPDATE
AS
IF @@rowcount = 0
RETURN
IF ( SELECT COUNT(*)
FROM Inserted
) > 1
BEGIN
PRINT 'Only one row at a time can be modified'
RETURN
END
IF UPDATE(year)
OR UPDATE(stu_code)
BEGIN
RAISERROR ( 'cannot change the year or the stu_code', 16, 1 )
ROLLBACK TRAN
RETURN
END
UPDATE dbo.t_badge
SET forename1 = i.forename1
, forename2 = i.forename2
, surname = i.surname
, dob = i.dob
, course = i.course
, end_date = i.end_date
FROM inserted i
WHERE i.year = t_badge.year
AND i.stu_code = t_badge.stu_code
RETURN
Note that I assumed that year and stu_code are the primary keys (I did not really look into the table definition you had)
The above will allow modifications to non-primary key columns, and only one row at a time.
Regards,
Andras