-- ================================================
-- Template generated from Template Explorer using:
-- Create Trigger (New Menu).SQL
--
-- Use the Specify Values for Template Parameters
-- command (Ctrl-Shift-M) to fill in the parameter
-- values below.
--
-- See additional Create Trigger templates for more
-- examples of different Trigger statements.
--
-- This block of comments will not be included in
-- the definition of the function.
-- ================================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
alter TRIGGER tgr_cbc_insert
ON checkbillc
AFTER INSERT
AS
BEGIN
declare @checkid varchar(32), @checkidx varchar(50) ,@checkicode varchar(50),@qty numeric(24, 6),@bookicodexx varchar(50),@gcode varchar(50),@gname varchar(50)
--更新后
select @checkid = checkid ,@checkidx=checkidx ,@checkicode=checkicode,@qty=qty ,@bookicodexx=bookicodexx,@gcode=gcode ,@gname=gname from inserted;
INSERT INTO checkbak
(checkid,checkidx,checkicode,qty,[bookicodexx],gcode,gname,[type])
VALUES
(@checkid,@checkidx,@checkicode,@qty,@bookicodexx,@gcode,@gname,'insert')
END
GO
alter TRIGGER tgr_cbc_delete
ON checkbillc
AFTER delete
AS
BEGIN
declare @checkid varchar(32), @checkidx varchar(50) ,@checkicode varchar(50),@qty numeric(24, 6),@bookicodexx varchar(50),@gcode varchar(50),@gname varchar(50)
--更新后
select @checkid = checkid ,@checkidx=checkidx ,@checkicode=checkicode,@qty=qty ,@bookicodexx=bookicodexx,@gcode=gcode ,@gname=gname from deleted;
INSERT INTO checkbak
(checkid,checkidx,checkicode,qty,[bookicodexx],gcode,gname,[type])
VALUES
(@checkid,@checkidx,@checkicode,@qty,@bookicodexx,@gcode,@gname,'delete')
END
GO
-- ================================================
-- Template generated from Template Explorer using:
-- Create Trigger (New Menu).SQL
--
-- Use the Specify Values for Template Parameters
-- command (Ctrl-Shift-M) to fill in the parameter
-- values below.
--
-- See additional Create Trigger templates for more
-- examples of different Trigger statements.
--
-- This block of comments will not be included in
-- the definition of the function.
-- ================================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
alter TRIGGER tgr_wb_update
ON warebalance
AFTER UPDATE
AS
BEGIN
declare @gid nvarchar(50)
set @gid =NEWID ()
declare @bid varchar(32), @gcode varchar(50) ,@gname varchar(50),@qty2 numeric(24, 6),@bookicodexx varchar(50)
declare @bid0 varchar(32), @gcode0 varchar(50) ,@gname0 varchar(50),@qty20 numeric(24, 6),@bookicodexx0 varchar(50)
--更新前的数据
select @bid = bid ,@gcode=gcode ,@gname=gname,@qty2=qty2 ,@bookicodexx=bookicodexx from deleted;
--更新后
select @bid0 = bid ,@gcode0=gcode ,@gname0=gname,@qty20=qty2 ,@bookicodexx0=bookicodexx from inserted;
INSERT INTO [warebak]
([bid],[gcode],[gname],[qty2],[bookicodexx],[gid])
VALUES
(@bid,@gcode,@gname,@qty2,@bookicodexx,@gid + 'delete')
INSERT INTO [warebak]
([bid],[gcode],[gname],[qty2],[bookicodexx],[gid])
VALUES
(@bid0,@gcode0,@gname0,@qty20,@bookicodexx0,@gid + 'insert')
END
GO
/****** Object: Table [dbo].[checkbak] Script Date: 12/11/2015 09:04:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[checkbak](
[id] [numeric](18, 0) IDENTITY(1,1) NOT NULL,
[checkid] [varchar](32) NULL,
[checkidx] [varchar](32) NULL,
[bookicodexx] [varchar](32) NULL,
[checkicode] [varchar](32) NULL,
[qty] [numeric](24, 6) NULL,
[gcode] [varchar](32) NULL,
[gname] [varchar](48) NULL,
[type] [varchar](50) NOT NULL,
CONSTRAINT [checkbak_pk] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[warebak] Script Date: 12/11/2015 09:05:10 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[warebak](
[bid] [varchar](32) NOT NULL,
[gcode] [nvarchar](50) NULL,
[gname] [nvarchar](50) NULL,
[qty2] [numeric](24, 6) NOT NULL,
[bookicodexx] [varchar](32) NULL,
[gid] [nvarchar](50) NOT NULL,
[id] [numeric](18, 0) IDENTITY(1,1) NOT NULL,
CONSTRAINT [warebak_pk] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [dbo].[warebak] ADD CONSTRAINT [DF__warebak__qty2__76B82F6D] DEFAULT ((0)) FOR [qty2]
GO
-- Template generated from Template Explorer using:
-- Create Trigger (New Menu).SQL
--
-- Use the Specify Values for Template Parameters
-- command (Ctrl-Shift-M) to fill in the parameter
-- values below.
--
-- See additional Create Trigger templates for more
-- examples of different Trigger statements.
--
-- This block of comments will not be included in
-- the definition of the function.
-- ================================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
alter TRIGGER tgr_cbc_insert
ON checkbillc
AFTER INSERT
AS
BEGIN
declare @checkid varchar(32), @checkidx varchar(50) ,@checkicode varchar(50),@qty numeric(24, 6),@bookicodexx varchar(50),@gcode varchar(50),@gname varchar(50)
--更新后
select @checkid = checkid ,@checkidx=checkidx ,@checkicode=checkicode,@qty=qty ,@bookicodexx=bookicodexx,@gcode=gcode ,@gname=gname from inserted;
INSERT INTO checkbak
(checkid,checkidx,checkicode,qty,[bookicodexx],gcode,gname,[type])
VALUES
(@checkid,@checkidx,@checkicode,@qty,@bookicodexx,@gcode,@gname,'insert')
END
GO
alter TRIGGER tgr_cbc_delete
ON checkbillc
AFTER delete
AS
BEGIN
declare @checkid varchar(32), @checkidx varchar(50) ,@checkicode varchar(50),@qty numeric(24, 6),@bookicodexx varchar(50),@gcode varchar(50),@gname varchar(50)
--更新后
select @checkid = checkid ,@checkidx=checkidx ,@checkicode=checkicode,@qty=qty ,@bookicodexx=bookicodexx,@gcode=gcode ,@gname=gname from deleted;
INSERT INTO checkbak
(checkid,checkidx,checkicode,qty,[bookicodexx],gcode,gname,[type])
VALUES
(@checkid,@checkidx,@checkicode,@qty,@bookicodexx,@gcode,@gname,'delete')
END
GO
-- ================================================
-- Template generated from Template Explorer using:
-- Create Trigger (New Menu).SQL
--
-- Use the Specify Values for Template Parameters
-- command (Ctrl-Shift-M) to fill in the parameter
-- values below.
--
-- See additional Create Trigger templates for more
-- examples of different Trigger statements.
--
-- This block of comments will not be included in
-- the definition of the function.
-- ================================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
alter TRIGGER tgr_wb_update
ON warebalance
AFTER UPDATE
AS
BEGIN
declare @gid nvarchar(50)
set @gid =NEWID ()
declare @bid varchar(32), @gcode varchar(50) ,@gname varchar(50),@qty2 numeric(24, 6),@bookicodexx varchar(50)
declare @bid0 varchar(32), @gcode0 varchar(50) ,@gname0 varchar(50),@qty20 numeric(24, 6),@bookicodexx0 varchar(50)
--更新前的数据
select @bid = bid ,@gcode=gcode ,@gname=gname,@qty2=qty2 ,@bookicodexx=bookicodexx from deleted;
--更新后
select @bid0 = bid ,@gcode0=gcode ,@gname0=gname,@qty20=qty2 ,@bookicodexx0=bookicodexx from inserted;
INSERT INTO [warebak]
([bid],[gcode],[gname],[qty2],[bookicodexx],[gid])
VALUES
(@bid,@gcode,@gname,@qty2,@bookicodexx,@gid + 'delete')
INSERT INTO [warebak]
([bid],[gcode],[gname],[qty2],[bookicodexx],[gid])
VALUES
(@bid0,@gcode0,@gname0,@qty20,@bookicodexx0,@gid + 'insert')
END
GO
/****** Object: Table [dbo].[checkbak] Script Date: 12/11/2015 09:04:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[checkbak](
[id] [numeric](18, 0) IDENTITY(1,1) NOT NULL,
[checkid] [varchar](32) NULL,
[checkidx] [varchar](32) NULL,
[bookicodexx] [varchar](32) NULL,
[checkicode] [varchar](32) NULL,
[qty] [numeric](24, 6) NULL,
[gcode] [varchar](32) NULL,
[gname] [varchar](48) NULL,
[type] [varchar](50) NOT NULL,
CONSTRAINT [checkbak_pk] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[warebak] Script Date: 12/11/2015 09:05:10 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[warebak](
[bid] [varchar](32) NOT NULL,
[gcode] [nvarchar](50) NULL,
[gname] [nvarchar](50) NULL,
[qty2] [numeric](24, 6) NOT NULL,
[bookicodexx] [varchar](32) NULL,
[gid] [nvarchar](50) NOT NULL,
[id] [numeric](18, 0) IDENTITY(1,1) NOT NULL,
CONSTRAINT [warebak_pk] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [dbo].[warebak] ADD CONSTRAINT [DF__warebak__qty2__76B82F6D] DEFAULT ((0)) FOR [qty2]
GO