Please, a SQL trigger question!!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alejandro

    Please, a SQL trigger question!!

    Hi! I have no experience at all using triggers, and I don't even know
    very well SQL server. I hope someone can help me with the folling: I
    need to know if it is possible to implement a trigger that monitors
    the value of an specific field, and when it changes the value from 0
    to 1 it should update the value of another field in another table but
    after some arithmetic operations. The arithmetics operations involves
    data within the same database.

    Is this can be made using triggers and stored procedures?
  • Dean Savovic

    #2
    Re: Please, a SQL trigger question!!

    Of course it can!

    Look for this key words in SQL BOL: triggers, after, 'if update', inserted tables, deleted tables.

    --
    Dean Savovic
    Teched Consulting Services Ltd. is one of the leading Croatian consultancy and software development companies providing bespoke consulting and IT services in the public and private sectors since 1996.



    "Alejandro" <alejandro_ceja @yahoo.com.mx> wrote in message news:85729932.0 311041500.64581 e86@posting.goo gle.com...[color=blue]
    > Hi! I have no experience at all using triggers, and I don't even know
    > very well SQL server. I hope someone can help me with the folling: I
    > need to know if it is possible to implement a trigger that monitors
    > the value of an specific field, and when it changes the value from 0
    > to 1 it should update the value of another field in another table but
    > after some arithmetic operations. The arithmetics operations involves
    > data within the same database.
    >
    > Is this can be made using triggers and stored procedures?[/color]


    Comment

    • WangKhar

      #3
      Re: Please, a SQL trigger question!!

      Yes it can.

      Personally Id recommend against it as I believe triggers to be the
      very personal work of satan.

      They can be quite slow - specially on heavy load tables, and have a
      bad habit of hiding away and getting lost when you move the
      database...

      But yes - sure you can do that.

      alejandro_ceja@ yahoo.com.mx (Alejandro) wrote in message news:<85729932. 0311041500.6458 1e86@posting.go ogle.com>...
      [color=blue]
      > Is this can be made using triggers and stored procedures?[/color]

      Comment

      • John Bell

        #4
        Re: Please, a SQL trigger question!!

        Hi

        SQL server does not have the ability to create a trigger on an
        individual column
        but you can check that a column has changed within a trigger but
        either comparing the values for that column in the inserted and
        deleted or possibly the COLUMNS_UPDATED clause (Although a column can
        be updated it may not be to a different value!).

        See the "CREATE TRIGGER" topic in Books Online or at:


        The examples given in this topic also who how to update other tables.

        HTH

        John

        alejandro_ceja@ yahoo.com.mx (Alejandro) wrote in message news:<85729932. 0311041500.6458 1e86@posting.go ogle.com>...[color=blue]
        > Hi! I have no experience at all using triggers, and I don't even know
        > very well SQL server. I hope someone can help me with the folling: I
        > need to know if it is possible to implement a trigger that monitors
        > the value of an specific field, and when it changes the value from 0
        > to 1 it should update the value of another field in another table but
        > after some arithmetic operations. The arithmetics operations involves
        > data within the same database.
        >
        > Is this can be made using triggers and stored procedures?[/color]

        Comment

        Working...