By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,934 Members | 1,366 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,934 IT Pros & Developers. It's quick & easy.

Please, a SQL trigger question!!

P: n/a
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?
Jul 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Of course it can!

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

--
Dean Savovic
www.teched.hr
"Alejandro" <al************@yahoo.com.mx> wrote in message news:85**************************@posting.google.c om...
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?

Jul 20 '05 #2

P: n/a
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.

al************@yahoo.com.mx (Alejandro) wrote in message news:<85**************************@posting.google. com>...
Is this can be made using triggers and stored procedures?

Jul 20 '05 #3

P: n/a
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:
http://msdn.microsoft.com/library/de...eate2_7eeq.asp

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

HTH

John

al************@yahoo.com.mx (Alejandro) wrote in message news:<85**************************@posting.google. com>...
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?

Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.