CREATE TRIGGER [triggerInsert]
ON [dbo].[emeDetail]
FOR INSERT
AS
insert into tWage (wID,wWage)
select inserted.emeNumber,1000 from inserted
CREATE TRIGGER [triggerDelete]
ON [dbo].[emeDetail]
FOR DELETE
AS
delete tWage from tWage tw,Deleted d
where tw.wID = d.emeNumber
create trigger [triggerUpdate]
on [dbo].[emeDetail]
for update
as
if Update(emeNumber)
Update tWage
Set wID = i.emeNumber
From tWage tw , Deleted d ,Inserted i --Deleted和Inserted临时表
Where tw.wID = d.emeNumber
表:
CREATE TABLE [dbo].[emeDetail](
[emeNumber] [char](40) COLLATE Chinese_PRC_CI_AS NOT NULL,
[emeName] [char](10) COLLATE Chinese_PRC_CI_AS NULL,
[emeSex] [char](4) COLLATE Chinese_PRC_CI_AS NULL,
[emeDepartment] [char](100) COLLATE Chinese_PRC_CI_AS NULL,
[emeTime] [datetime] NULL,
CONSTRAINT [PK_emeDetail] PRIMARY KEY CLUSTERED
(
[emeNumber] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
CREATE TABLE [dbo].[tWage](
[wID] [char](40) COLLATE Chinese_PRC_CI_AS NOT NULL,
[wWage] [char](50) COLLATE Chinese_PRC_CI_AS NULL,
CONSTRAINT [PK_tWage] PRIMARY KEY CLUSTERED
(
[wID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
ON [dbo].[emeDetail]
FOR INSERT
AS
insert into tWage (wID,wWage)
select inserted.emeNumber,1000 from inserted
CREATE TRIGGER [triggerDelete]
ON [dbo].[emeDetail]
FOR DELETE
AS
delete tWage from tWage tw,Deleted d
where tw.wID = d.emeNumber
create trigger [triggerUpdate]
on [dbo].[emeDetail]
for update
as
if Update(emeNumber)
Update tWage
Set wID = i.emeNumber
From tWage tw , Deleted d ,Inserted i --Deleted和Inserted临时表
Where tw.wID = d.emeNumber
表:
CREATE TABLE [dbo].[emeDetail](
[emeNumber] [char](40) COLLATE Chinese_PRC_CI_AS NOT NULL,
[emeName] [char](10) COLLATE Chinese_PRC_CI_AS NULL,
[emeSex] [char](4) COLLATE Chinese_PRC_CI_AS NULL,
[emeDepartment] [char](100) COLLATE Chinese_PRC_CI_AS NULL,
[emeTime] [datetime] NULL,
CONSTRAINT [PK_emeDetail] PRIMARY KEY CLUSTERED
(
[emeNumber] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
CREATE TABLE [dbo].[tWage](
[wID] [char](40) COLLATE Chinese_PRC_CI_AS NOT NULL,
[wWage] [char](50) COLLATE Chinese_PRC_CI_AS NULL,
CONSTRAINT [PK_tWage] PRIMARY KEY CLUSTERED
(
[wID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]