Hi Group Members
Description of table ALPHA
col1int
col2int
col3int
Description of table BETA
tar1int
tar2int
tar3int
I would like create an update trigger for any update on ALPHA table
it should be reflected rightaway on BETA table.
Thanks and good luck
I'm assuming that col1 & tar1 are FK with a 1-to-1, and col2/3 & tar2/3
are the columns you want to carry the updates to - but something like
this should work:
CREATE TRIGGER utr_AlphaBeta ON ALPHA
FOR UPDATE
AS
BEGIN
UPDATEBETA
SETBETA.tar2 = INSERTED.col2,
BETA.tar3 = INSERTED.col3
FROMINSERTED,BETA
WHEREINSERTED.col1 = BETA.tar1
END
.....and good luck to you.
kevincristo@.gmail.com wrote:
> Hi Group Members
>
> Description of table ALPHA
> col1int
> col2int
> col3int
>
> Description of table BETA
> tar1int
> tar2int
> tar3int
> I would like create an update trigger for any update on ALPHA table
> it should be reflected rightaway on BETA table.
> Thanks and good luck
|||On 23 Mar 2006 12:49:37 -0800, kevincristo@.gmail.com wrote:
>Hi Group Members
>
>Description of table ALPHA
>col1int
>col2int
>col3int
>
>Description of table BETA
>tar1int
>tar2int
>tar3int
>I would like create an update trigger for any update on ALPHA table
>it should be reflected rightaway on BETA table.
>Thanks and good luck
Hi kevincristo,
Best solution, IMO:
DROP TABLE Beta
go
CREATE VIEW Beta
AS
SELECT col1 AS tar1, col2 AS tar2, col33 AS tar3
FROM Alpha
go
Hugo Kornelis, SQL Server MVP
Showing posts with label membersdescription. Show all posts
Showing posts with label membersdescription. Show all posts
Monday, February 13, 2012
***Update Trigger ***
Hi Group Members
Description of table ALPHA
col1 int
col2 int
col3 int
Description of table BETA
tar1 int
tar2 int
tar3 int
I would like create an update trigger for any update on ALPHA table
it should be reflected rightaway on BETA table.
Thanks and good luckI'm assuming that col1 & tar1 are FK with a 1-to-1, and col2/3 & tar2/3
are the columns you want to carry the updates to - but something like
this should work:
CREATE TRIGGER utr_AlphaBeta ON ALPHA
FOR UPDATE
AS
BEGIN
UPDATE BETA
SET BETA.tar2 = INSERTED.col2,
BETA.tar3 = INSERTED.col3
FROM INSERTED,BETA
WHERE INSERTED.col1 = BETA.tar1
END
....and good luck to you.
kevincristo@.gmail.com wrote:
> Hi Group Members
>
> Description of table ALPHA
> col1 int
> col2 int
> col3 int
>
> Description of table BETA
> tar1 int
> tar2 int
> tar3 int
> I would like create an update trigger for any update on ALPHA table
> it should be reflected rightaway on BETA table.
> Thanks and good luck|||On 23 Mar 2006 12:49:37 -0800, kevincristo@.gmail.com wrote:
>Hi Group Members
>
>Description of table ALPHA
>col1 int
>col2 int
>col3 int
>
>Description of table BETA
>tar1 int
>tar2 int
>tar3 int
>I would like create an update trigger for any update on ALPHA table
>it should be reflected rightaway on BETA table.
>Thanks and good luck
Hi kevincristo,
Best solution, IMO:
DROP TABLE Beta
go
CREATE VIEW Beta
AS
SELECT col1 AS tar1, col2 AS tar2, col33 AS tar3
FROM Alpha
go
Hugo Kornelis, SQL Server MVP
Description of table ALPHA
col1 int
col2 int
col3 int
Description of table BETA
tar1 int
tar2 int
tar3 int
I would like create an update trigger for any update on ALPHA table
it should be reflected rightaway on BETA table.
Thanks and good luckI'm assuming that col1 & tar1 are FK with a 1-to-1, and col2/3 & tar2/3
are the columns you want to carry the updates to - but something like
this should work:
CREATE TRIGGER utr_AlphaBeta ON ALPHA
FOR UPDATE
AS
BEGIN
UPDATE BETA
SET BETA.tar2 = INSERTED.col2,
BETA.tar3 = INSERTED.col3
FROM INSERTED,BETA
WHERE INSERTED.col1 = BETA.tar1
END
....and good luck to you.
kevincristo@.gmail.com wrote:
> Hi Group Members
>
> Description of table ALPHA
> col1 int
> col2 int
> col3 int
>
> Description of table BETA
> tar1 int
> tar2 int
> tar3 int
> I would like create an update trigger for any update on ALPHA table
> it should be reflected rightaway on BETA table.
> Thanks and good luck|||On 23 Mar 2006 12:49:37 -0800, kevincristo@.gmail.com wrote:
>Hi Group Members
>
>Description of table ALPHA
>col1 int
>col2 int
>col3 int
>
>Description of table BETA
>tar1 int
>tar2 int
>tar3 int
>I would like create an update trigger for any update on ALPHA table
>it should be reflected rightaway on BETA table.
>Thanks and good luck
Hi kevincristo,
Best solution, IMO:
DROP TABLE Beta
go
CREATE VIEW Beta
AS
SELECT col1 AS tar1, col2 AS tar2, col33 AS tar3
FROM Alpha
go
Hugo Kornelis, SQL Server MVP
Subscribe to:
Posts (Atom)