 
if exists (select * from dbo.sysobjects where  name = 'Repository_Ins' and type = 'TR') drop trigger Repository_Ins;
go

create trigger dbo.Repository_Ins on dbo.Repository for Insert
as
--**************************************************************************
--   Trigger: Repository_Ins
--    Author: Ron Savage
--      Date: 09/28/2008
--
-- Description:
-- This trigger just puts a copy of the inserted row into the
-- Repository_History table.
--
-- Modification History:
-- Date        Init  Comment
-- 09/28/2008  RS    Created.
--**************************************************************************
begin
   --***********************************************************************
   -- Put a copy in the history table, get the config_content from the
   -- orginal table because TEXT data type fields aren't available in
   -- the "Inserted" table.
   --***********************************************************************
   Insert into Repository_History
      select
         i.config_id,
         i.filename,
         i.created_by,
         i.created_system,
         i.create_date,
         i.updated_by,
         i.updated_system,
         i.last_updated,
         d.content
      from
         Inserted i

         JOIN Repository d
            on (d.config_id = i.config_id);
end
go
