Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Triggers: Manipulating a table when comparing 2 tables.

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-05-30 : 09:41:25
Jason writes "Hopefully this will clear up the subject. I'm am looking at two tables. When i compare them, i look for a common ID. Afterwards, i want to to 1 of 3 things

1) run an UPDATE statement that changes a boolean value to True on every record that have a matching ID #.

2) run an INSERT statement that adds a record from Table1 to Table2, if the record is not on Table2.

3) run an UPDATE that changes a boolean value to False on every record that is on Table2 but not Table1.

The catch is, this is all being done in a trigger.

I have the syntax to compare two tables:
(this just an example)
select F.SeqOrder, FA.SeqOrder, F.theQuestion, FA.theQuestion, F.theAnswer, FA.theAnswer, FA.in_FAQ
from FAQ F, FAQ2 FA
where F.ID = FA.ID;

Oh yeah.. SQL 7 - SP2"
   

- Advertisement -