eksemplerne i manualen antyder at man typisk bruger begge:
CREATE TRIGGER employee_insupd ON employee FOR INSERT, UPDATE AS /* Get the range of level for this job type from the jobs table. */ DECLARE @@MIN_LVL tinyint, @@MAX_LVL tinyint, @@EMP_LVL tinyint, @@JOB_ID smallint SELECT @@MIN_LVl = min_lvl, @@MAX_LV = max_lvl, @@ EMP_LVL = i.job_lvl, @@JOB_ID = i.job_id FROM employee e, jobs j, inserted i WHERE e.emp_id = i.emp_id AND i.job_id = j.job_id IF (@@JOB_ID = 1) and (@@EMP_lVl <> 10) BEGIN RAISERROR ('Job id 1 expects the default level of 10.', 16, 1) ROLLBACK TRANSACTION END ELSE IF NOT @@ EMP_LVL BETWEEN @@MIN_LVL AND @@MAX_LVL) BEGIN RAISERROR ('The level for job_id:%d should be between %d and %d.', 16, 1, @@JOB_ID, @@MIN_LVL, @@MAX_LVL) ROLLBACK TRANSACTION END
men jeg troede faktisk at en RAISEERROR var nok til at abortere en insert. Nå - jeg må huske forkert.
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.