ralph_rea
asked on
trigger sql server
Hi,
I've these tables:
CREATE TABLE [afm].[wr](
[ac_id] [char](32) NULL DEFAULT (null),
[wo_id] [int] NULL DEFAULT (null),
[wr_id] [int] IDENTITY(1,1) NOT NULL)
CREATE TABLE [afm].[wo](
[ac_id] [char](32) NULL DEFAULT (null),
[wo_id] [int] IDENTITY(1,1) NOT NULL)
I'd like to create a trigger that fire when:
- update or insert into wr
- wr.wo_id is not null and wr.wo_id=wo.wo_id
this trigger have to update wo.ac_id with wr.ac_id values
How can I write this trigger?
Thanks in advance!
Raf
I've these tables:
CREATE TABLE [afm].[wr](
[ac_id] [char](32) NULL DEFAULT (null),
[wo_id] [int] NULL DEFAULT (null),
[wr_id] [int] IDENTITY(1,1) NOT NULL)
CREATE TABLE [afm].[wo](
[ac_id] [char](32) NULL DEFAULT (null),
[wo_id] [int] IDENTITY(1,1) NOT NULL)
I'd like to create a trigger that fire when:
- update or insert into wr
- wr.wo_id is not null and wr.wo_id=wo.wo_id
this trigger have to update wo.ac_id with wr.ac_id values
How can I write this trigger?
Thanks in advance!
Raf
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
the steps are:
insert into wr (trigger not file because wo_id is null)
update wr.wo_id with one value (here trigger must fire and update wo.ac_id with wr.ac_id values)