Results 1 to 2 of 2
  1. #1
    Join Date
    May 2010
    Posts
    2

    Unanswered: instead of insert

    Hi all

    i am trying to understand somthing about triggers
    hope some one could help me

    if i want to prevent user from inserting wrong data to my DB
    i will have a BL that will prevent it
    but still i am not fully protected

    what i want is to create a trigger that will check the inserted data
    before i am doing the insert to the table
    for example

    trigger myTrigger on MyTable instead of insert
    as
    if ???? <-DONT KNOW THIS PART(WANT TO CHECK THE INSERTED DATA
    begin
    raiserror ....
    rollback transaction
    end

    end

    thanks

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    If you checks can be done using a CHECK CONSTRAINT, I'd recommend using them very strongly over triggers.

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •