|
Posted by Yas on 08/16/07 21:37
On 16 Aug, 17:48, Roy Harvey <roy_har...@snet.net> wrote:
> On Thu, 16 Aug 2007 08:13:47 -0700, Yas <yas...@gmail.com> wrote:
> >> 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?
>
> Read up on the INSERTED and DELETED virtual tables that are available
> to triggers.
Hi I'm trying the following for INSERT trigger attached to Table1 but
it doesn't seem to work in that it doesn't insert the new rows into
Table2 from Table1
CREATE TRIGGER my_Trigger ON [dbo].[Table2]
FOR INSERT
AS
INSERT INTO
Table2(STATUS,attribute15,email,lastname1,lastname2,name,company,startDate)
SELECT 'Active' AS STATUS, b.Attribute15, b.email, b.lastname1,
b.lastname2, b.name,
b.company, b.startDate
FROM Inserted b LEFT OUTER JOIN
Table2 a ON b.Attribute15 = a.Attribute15
WHERE a.Attribute15 IS NULL
GO
The syntax according to MS SQL server is correct but nothing happens
when a new row is inserted into Table1.
The idea here is basically when a new row is inserted in Table1, the
above insert command is run and the new row copied over to Table2
Any help?
Thanks in advance
Navigation:
[Reply to this message]
|