-- This script is produced by the Audit generator. --**************************************************************** --******************** Table authors ******************** ALTER TABLE authors ADD row_id int identity(1,1) go --************************************************** -- Table a_authors --************************************************** if exists (select * from dbo.sysobjects where name = 'a_authors' and type = 'U') drop table dbo.a_authors GO CREATE TABLE dbo.a_authors ( audit_ID int identity(1,1) not null PRIMARY KEY CLUSTERED, modid int not null , au_id id NOT NULL , au_lname varchar(40) NOT NULL , au_fname varchar(20) NOT NULL , phone char(12) NOT NULL , address varchar(40) NULL , city varchar(20) NULL , state char(2) NULL , zip char(5) NULL , contract bit NOT NULL ) GO --************************************************** --************************************************** -- Trigger for table authors --************************************************** if exists (select * from dbo.sysobjects where name = 't_authors_A' and type = 'TR' ) drop trigger dbo.t_authors_A GO SET QUOTED_IDENTIFIER ON SET ANSI_NULLS ON GO CREATE TRIGGER t_authors_A ON authors AFTER INSERT,UPDATE,DELETE AS BEGIN declare @tblname varchar(128) SET NOCOUNT ON set @tblname = 'authors' select * into #td from deleted select * into #ti from inserted exec dbo.P_TRIGGER @tblname = @tblname end SET NOCOUNT OFF END GO SET QUOTED_IDENTIFIER OFF SET ANSI_NULLS ON GO sp_settriggerorder @triggername= 't_authors_A', @order='LAST', @stmttype = 'INSERT' GO sp_settriggerorder @triggername= 't_authors_A', @order='LAST', @stmttype = 'UPDATE' GO sp_settriggerorder @triggername= 't_authors_A', @order='LAST', @stmttype = 'DELETE' GO --************************************************** --******************** Table discounts ******************** ALTER TABLE discounts ADD row_id int identity(1,1) go --************************************************** -- Table a_discounts --************************************************** if exists (select * from dbo.sysobjects where name = 'a_discounts' and type = 'U') drop table dbo.a_discounts GO CREATE TABLE dbo.a_discounts ( audit_ID int identity(1,1) not null PRIMARY KEY CLUSTERED, modid int not null , discounttype varchar(40) NOT NULL , stor_id char(4) NULL , lowqty smallint NULL , highqty smallint NULL , discount decimal ( 4,2) NOT NULL ) GO --************************************************** --************************************************** -- Trigger for table discounts --************************************************** if exists (select * from dbo.sysobjects where name = 't_discounts_A' and type = 'TR' ) drop trigger dbo.t_discounts_A GO SET QUOTED_IDENTIFIER ON SET ANSI_NULLS ON GO CREATE TRIGGER t_discounts_A ON discounts AFTER INSERT,UPDATE,DELETE AS BEGIN declare @tblname varchar(128) SET NOCOUNT ON set @tblname = 'discounts' select * into #td from deleted select * into #ti from inserted exec dbo.P_TRIGGER @tblname = @tblname end SET NOCOUNT OFF END GO SET QUOTED_IDENTIFIER OFF SET ANSI_NULLS ON GO sp_settriggerorder @triggername= 't_discounts_A', @order='LAST', @stmttype = 'INSERT' GO sp_settriggerorder @triggername= 't_discounts_A', @order='LAST', @stmttype = 'UPDATE' GO sp_settriggerorder @triggername= 't_discounts_A', @order='LAST', @stmttype = 'DELETE' GO --************************************************** --******************** Table employee ******************** ALTER TABLE employee ADD row_id int identity(1,1) go --************************************************** -- Table a_employee --************************************************** if exists (select * from dbo.sysobjects where name = 'a_employee' and type = 'U') drop table dbo.a_employee GO CREATE TABLE dbo.a_employee ( audit_ID int identity(1,1) not null PRIMARY KEY CLUSTERED, modid int not null , emp_id empid NOT NULL , fname varchar(20) NOT NULL , minit char(1) NULL , lname varchar(30) NOT NULL , job_id smallint NOT NULL , job_lvl tinyint NULL , pub_id char(4) NOT NULL , hire_date datetime NOT NULL ) GO --************************************************** --************************************************** -- Trigger for table employee --************************************************** if exists (select * from dbo.sysobjects where name = 't_employee_A' and type = 'TR' ) drop trigger dbo.t_employee_A GO SET QUOTED_IDENTIFIER ON SET ANSI_NULLS ON GO CREATE TRIGGER t_employee_A ON employee AFTER INSERT,UPDATE,DELETE AS BEGIN declare @tblname varchar(128) SET NOCOUNT ON set @tblname = 'employee' select * into #td from deleted select * into #ti from inserted exec dbo.P_TRIGGER @tblname = @tblname end SET NOCOUNT OFF END GO SET QUOTED_IDENTIFIER OFF SET ANSI_NULLS ON GO sp_settriggerorder @triggername= 't_employee_A', @order='LAST', @stmttype = 'INSERT' GO sp_settriggerorder @triggername= 't_employee_A', @order='LAST', @stmttype = 'UPDATE' GO sp_settriggerorder @triggername= 't_employee_A', @order='LAST', @stmttype = 'DELETE' GO --************************************************** --******************** Table jobs ******************** ALTER TABLE jobs ADD row_id as job_id go --************************************************** -- Table a_jobs --************************************************** if exists (select * from dbo.sysobjects where name = 'a_jobs' and type = 'U') drop table dbo.a_jobs GO CREATE TABLE dbo.a_jobs ( audit_ID int identity(1,1) not null PRIMARY KEY CLUSTERED, modid int not null , job_id smallint identity NOT NULL , job_desc varchar(50) NOT NULL , min_lvl tinyint NOT NULL , max_lvl tinyint NOT NULL ) GO --************************************************** --************************************************** -- Trigger for table jobs --************************************************** if exists (select * from dbo.sysobjects where name = 't_jobs_A' and type = 'TR' ) drop trigger dbo.t_jobs_A GO SET QUOTED_IDENTIFIER ON SET ANSI_NULLS ON GO CREATE TRIGGER t_jobs_A ON jobs AFTER INSERT,UPDATE,DELETE AS BEGIN declare @tblname varchar(128) SET NOCOUNT ON set @tblname = 'jobs' select * into #td from deleted select * into #ti from inserted exec dbo.P_TRIGGER @tblname = @tblname end SET NOCOUNT OFF END GO SET QUOTED_IDENTIFIER OFF SET ANSI_NULLS ON GO sp_settriggerorder @triggername= 't_jobs_A', @order='LAST', @stmttype = 'INSERT' GO sp_settriggerorder @triggername= 't_jobs_A', @order='LAST', @stmttype = 'UPDATE' GO sp_settriggerorder @triggername= 't_jobs_A', @order='LAST', @stmttype = 'DELETE' GO --************************************************** --******************** Table pub_info ******************** ALTER TABLE pub_info ADD row_id int identity(1,1) go --************************************************** -- Table a_pub_info --************************************************** if exists (select * from dbo.sysobjects where name = 'a_pub_info' and type = 'U') drop table dbo.a_pub_info GO CREATE TABLE dbo.a_pub_info ( audit_ID int identity(1,1) not null PRIMARY KEY CLUSTERED, modid int not null , pub_id char(4) NOT NULL , logo image NULL , pr_info text NULL ) GO --************************************************** --************************************************** -- Trigger for table pub_info --************************************************** if exists (select * from dbo.sysobjects where name = 't_pub_info_A' and type = 'TR' ) drop trigger dbo.t_pub_info_A GO SET QUOTED_IDENTIFIER ON SET ANSI_NULLS ON GO CREATE TRIGGER t_pub_info_A ON pub_info AFTER INSERT,UPDATE,DELETE AS BEGIN declare @tblname varchar(128) SET NOCOUNT ON set @tblname = 'pub_info' select * into #td from deleted select * into #ti from inserted exec dbo.P_TRIGGER @tblname = @tblname end SET NOCOUNT OFF END GO SET QUOTED_IDENTIFIER OFF SET ANSI_NULLS ON GO sp_settriggerorder @triggername= 't_pub_info_A', @order='LAST', @stmttype = 'INSERT' GO sp_settriggerorder @triggername= 't_pub_info_A', @order='LAST', @stmttype = 'UPDATE' GO sp_settriggerorder @triggername= 't_pub_info_A', @order='LAST', @stmttype = 'DELETE' GO --************************************************** --******************** Table publishers ******************** ALTER TABLE publishers ADD row_id int identity(1,1) go --************************************************** -- Table a_publishers --************************************************** if exists (select * from dbo.sysobjects where name = 'a_publishers' and type = 'U') drop table dbo.a_publishers GO CREATE TABLE dbo.a_publishers ( audit_ID int identity(1,1) not null PRIMARY KEY CLUSTERED, modid int not null , pub_id char(4) NOT NULL , pub_name varchar(40) NULL , city varchar(20) NULL , state char(2) NULL , country varchar(30) NULL ) GO --************************************************** --************************************************** -- Trigger for table publishers --************************************************** if exists (select * from dbo.sysobjects where name = 't_publishers_A' and type = 'TR' ) drop trigger dbo.t_publishers_A GO SET QUOTED_IDENTIFIER ON SET ANSI_NULLS ON GO CREATE TRIGGER t_publishers_A ON publishers AFTER INSERT,UPDATE,DELETE AS BEGIN declare @tblname varchar(128) SET NOCOUNT ON set @tblname = 'publishers' select * into #td from deleted select * into #ti from inserted exec dbo.P_TRIGGER @tblname = @tblname end SET NOCOUNT OFF END GO SET QUOTED_IDENTIFIER OFF SET ANSI_NULLS ON GO sp_settriggerorder @triggername= 't_publishers_A', @order='LAST', @stmttype = 'INSERT' GO sp_settriggerorder @triggername= 't_publishers_A', @order='LAST', @stmttype = 'UPDATE' GO sp_settriggerorder @triggername= 't_publishers_A', @order='LAST', @stmttype = 'DELETE' GO --************************************************** --******************** Table roysched ******************** ALTER TABLE roysched ADD row_id int identity(1,1) go --************************************************** -- Table a_roysched --************************************************** if exists (select * from dbo.sysobjects where name = 'a_roysched' and type = 'U') drop table dbo.a_roysched GO CREATE TABLE dbo.a_roysched ( audit_ID int identity(1,1) not null PRIMARY KEY CLUSTERED, modid int not null , title_id tid NOT NULL , lorange int NULL , hirange int NULL , royalty int NULL ) GO --************************************************** --************************************************** -- Trigger for table roysched --************************************************** if exists (select * from dbo.sysobjects where name = 't_roysched_A' and type = 'TR' ) drop trigger dbo.t_roysched_A GO SET QUOTED_IDENTIFIER ON SET ANSI_NULLS ON GO CREATE TRIGGER t_roysched_A ON roysched AFTER INSERT,UPDATE,DELETE AS BEGIN declare @tblname varchar(128) SET NOCOUNT ON set @tblname = 'roysched' select * into #td from deleted select * into #ti from inserted exec dbo.P_TRIGGER @tblname = @tblname end SET NOCOUNT OFF END GO SET QUOTED_IDENTIFIER OFF SET ANSI_NULLS ON GO sp_settriggerorder @triggername= 't_roysched_A', @order='LAST', @stmttype = 'INSERT' GO sp_settriggerorder @triggername= 't_roysched_A', @order='LAST', @stmttype = 'UPDATE' GO sp_settriggerorder @triggername= 't_roysched_A', @order='LAST', @stmttype = 'DELETE' GO --************************************************** --******************** Table sales ******************** ALTER TABLE sales ADD row_id int identity(1,1) go --************************************************** -- Table a_sales --************************************************** if exists (select * from dbo.sysobjects where name = 'a_sales' and type = 'U') drop table dbo.a_sales GO CREATE TABLE dbo.a_sales ( audit_ID int identity(1,1) not null PRIMARY KEY CLUSTERED, modid int not null , stor_id char(4) NOT NULL , ord_num varchar(20) NOT NULL , ord_date datetime NOT NULL , qty smallint NOT NULL , payterms varchar(12) NOT NULL , title_id tid NOT NULL ) GO --************************************************** --************************************************** -- Trigger for table sales --************************************************** if exists (select * from dbo.sysobjects where name = 't_sales_A' and type = 'TR' ) drop trigger dbo.t_sales_A GO SET QUOTED_IDENTIFIER ON SET ANSI_NULLS ON GO CREATE TRIGGER t_sales_A ON sales AFTER INSERT,UPDATE,DELETE AS BEGIN declare @tblname varchar(128) SET NOCOUNT ON set @tblname = 'sales' select * into #td from deleted select * into #ti from inserted exec dbo.P_TRIGGER @tblname = @tblname end SET NOCOUNT OFF END GO SET QUOTED_IDENTIFIER OFF SET ANSI_NULLS ON GO sp_settriggerorder @triggername= 't_sales_A', @order='LAST', @stmttype = 'INSERT' GO sp_settriggerorder @triggername= 't_sales_A', @order='LAST', @stmttype = 'UPDATE' GO sp_settriggerorder @triggername= 't_sales_A', @order='LAST', @stmttype = 'DELETE' GO --************************************************** --******************** Table stores ******************** ALTER TABLE stores ADD row_id int identity(1,1) go --************************************************** -- Table a_stores --************************************************** if exists (select * from dbo.sysobjects where name = 'a_stores' and type = 'U') drop table dbo.a_stores GO CREATE TABLE dbo.a_stores ( audit_ID int identity(1,1) not null PRIMARY KEY CLUSTERED, modid int not null , stor_id char(4) NOT NULL , stor_name varchar(40) NULL , stor_address varchar(40) NULL , city varchar(20) NULL , state char(2) NULL , zip char(5) NULL ) GO --************************************************** --************************************************** -- Trigger for table stores --************************************************** if exists (select * from dbo.sysobjects where name = 't_stores_A' and type = 'TR' ) drop trigger dbo.t_stores_A GO SET QUOTED_IDENTIFIER ON SET ANSI_NULLS ON GO CREATE TRIGGER t_stores_A ON stores AFTER INSERT,UPDATE,DELETE AS BEGIN declare @tblname varchar(128) SET NOCOUNT ON set @tblname = 'stores' select * into #td from deleted select * into #ti from inserted exec dbo.P_TRIGGER @tblname = @tblname end SET NOCOUNT OFF END GO SET QUOTED_IDENTIFIER OFF SET ANSI_NULLS ON GO sp_settriggerorder @triggername= 't_stores_A', @order='LAST', @stmttype = 'INSERT' GO sp_settriggerorder @triggername= 't_stores_A', @order='LAST', @stmttype = 'UPDATE' GO sp_settriggerorder @triggername= 't_stores_A', @order='LAST', @stmttype = 'DELETE' GO --************************************************** --******************** Table titleauthor ******************** ALTER TABLE titleauthor ADD row_id int identity(1,1) go --************************************************** -- Table a_titleauthor --************************************************** if exists (select * from dbo.sysobjects where name = 'a_titleauthor' and type = 'U') drop table dbo.a_titleauthor GO CREATE TABLE dbo.a_titleauthor ( audit_ID int identity(1,1) not null PRIMARY KEY CLUSTERED, modid int not null , au_id id NOT NULL , title_id tid NOT NULL , au_ord tinyint NULL , royaltyper int NULL ) GO --************************************************** --************************************************** -- Trigger for table titleauthor --************************************************** if exists (select * from dbo.sysobjects where name = 't_titleauthor_A' and type = 'TR' ) drop trigger dbo.t_titleauthor_A GO SET QUOTED_IDENTIFIER ON SET ANSI_NULLS ON GO CREATE TRIGGER t_titleauthor_A ON titleauthor AFTER INSERT,UPDATE,DELETE AS BEGIN declare @tblname varchar(128) SET NOCOUNT ON set @tblname = 'titleauthor' select * into #td from deleted select * into #ti from inserted exec dbo.P_TRIGGER @tblname = @tblname end SET NOCOUNT OFF END GO SET QUOTED_IDENTIFIER OFF SET ANSI_NULLS ON GO sp_settriggerorder @triggername= 't_titleauthor_A', @order='LAST', @stmttype = 'INSERT' GO sp_settriggerorder @triggername= 't_titleauthor_A', @order='LAST', @stmttype = 'UPDATE' GO sp_settriggerorder @triggername= 't_titleauthor_A', @order='LAST', @stmttype = 'DELETE' GO --************************************************** --******************** Table titles ******************** ALTER TABLE titles ADD row_id int identity(1,1) go --************************************************** -- Table a_titles --************************************************** if exists (select * from dbo.sysobjects where name = 'a_titles' and type = 'U') drop table dbo.a_titles GO CREATE TABLE dbo.a_titles ( audit_ID int identity(1,1) not null PRIMARY KEY CLUSTERED, modid int not null , title_id tid NOT NULL , title varchar(80) NOT NULL , type char(12) NOT NULL , pub_id char(4) NULL , price money NULL , advance money NULL , royalty int NULL , ytd_sales int NULL , notes varchar(200) NULL , pubdate datetime NOT NULL ) GO --************************************************** --************************************************** -- Trigger for table titles --************************************************** if exists (select * from dbo.sysobjects where name = 't_titles_A' and type = 'TR' ) drop trigger dbo.t_titles_A GO SET QUOTED_IDENTIFIER ON SET ANSI_NULLS ON GO CREATE TRIGGER t_titles_A ON titles AFTER INSERT,UPDATE,DELETE AS BEGIN declare @tblname varchar(128) SET NOCOUNT ON set @tblname = 'titles' select * into #td from deleted select * into #ti from inserted exec dbo.P_TRIGGER @tblname = @tblname end SET NOCOUNT OFF END GO SET QUOTED_IDENTIFIER OFF SET ANSI_NULLS ON GO sp_settriggerorder @triggername= 't_titles_A', @order='LAST', @stmttype = 'INSERT' GO sp_settriggerorder @triggername= 't_titles_A', @order='LAST', @stmttype = 'UPDATE' GO sp_settriggerorder @triggername= 't_titles_A', @order='LAST', @stmttype = 'DELETE' GO --**************************************************