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

Trigger problem

P: n/a
Hi Folks,

My basic requirement is I want to write a trigger on a table based on
certain conditions post-update from another table in another database.

The actors in this scenario are:
Database D1, Table T1
Database D2, Table T2, T3

Action:
T1 updates T2

Requirement:
As soon as T2 is updated, I need to trigger an insert onto T3.
However, I do not want this action to be performed on every update on
T2 (other sources also update T2).
I want the trigger only for updates from T1.
I do not know how to go about it (conditional syntax for the update?)

I urgently require to solve this problem.
Thanks in advance for all those pitching in with help.

Best Regards,
Manoj S. Panicker
Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Sorry I forgot to include the version of MS-SQL server. It is MS-SQL 7.0.
ma***@direct2s.com (Manoj S. P.) wrote in message news:<26*************************@posting.google.c om>...
Hi Folks,

My basic requirement is I want to write a trigger on a table based on
certain conditions post-update from another table in another database.

The actors in this scenario are:
Database D1, Table T1
Database D2, Table T2, T3

Action:
T1 updates T2

Requirement:
As soon as T2 is updated, I need to trigger an insert onto T3.
However, I do not want this action to be performed on every update on
T2 (other sources also update T2).
I want the trigger only for updates from T1.
I do not know how to go about it (conditional syntax for the update?)

I urgently require to solve this problem.
Thanks in advance for all those pitching in with help.

Best Regards,
Manoj S. Panicker

Jul 20 '05 #2

P: n/a
[posted and mailed, please reply in news]

Manoj S. P. (ma***@direct2s.com) writes:
My basic requirement is I want to write a trigger on a table based on
certain conditions post-update from another table in another database.

The actors in this scenario are:
Database D1, Table T1
Database D2, Table T2, T3

Action:
T1 updates T2

Requirement:
As soon as T2 is updated, I need to trigger an insert onto T3.
However, I do not want this action to be performed on every update on
T2 (other sources also update T2).
I want the trigger only for updates from T1.
I do not know how to go about it (conditional syntax for the update?)


If I understand this correctly, you have a trigger on T1 that updates T2,
and when T2 is updated through this trigger you want to cascade to T3,
but not when T2 is updated from other places.

This is a kind of odd thing to do, but it is actually possible. In T1
create a temp table, call it #do$updateT3, and in T2 you do:

IF object_id('tempdb..#do$updateT3') IS NOT NULL
UPDATE T3 ...

It doesn't matter what columns you have in the temp table, or if
there is any data. It's the table itself that serves as a global
flag variable.
--
Erland Sommarskog, SQL Server MVP, so****@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.