|
Posted by Yas on 08/16/07 15:13
On 16 Aug, 15:16, Erland Sommarskog <esq...@sommarskog.se> wrote:
> Yas (yas...@gmail.com) writes:
> > Hi, sorry perhaps I should have been a bit more clear. Well, Table2 is
> > essentially a Master table that will have a record of all users that
> > were ever added to Table1. So even if at a later date userA and userB
> > were removed from Table1, a record of UserA and UserB will always be
> > there in Table2.
>
> > So yes right now Table1 and 2 are identical and that seems
> > pointless...however soon Table2 will be different in that it will have
> > a record of rows that are no longer present in Table1. I'm keeping
> > track of them via another method which checks if a row has been
> > removed from Table1 if so it adds the date of removal to a column of
> > that row in Table2. This is why I dont want to update Table2 if a row
> > is removed in Table1...only if a new row is added or an existing one
> > modified.
>
> > I hope that explains what I'm trying to do :-) can I still use
> > Triggers to do this?
>
> Since the tables are in the same database, triggers is definitely the
> way to go.
>
Thanks. This is what I'm trying to do now... do you know how I can
refer to the row that has just been added or modified?
In Table1 I have...
CREATE TRIGGER (tr_updateMaster) ON dbo.Table2
FOR INSERT, UPDATE
AS
Here I would like to put something like...
Insert into Table2 new row + 2 extra columns (status and date)
AND/OR
Update modified row in dbo.Table2 with different values in Table1
Thanks again :-)
Navigation:
[Reply to this message]
|