Create SQL Log file

I need a good idea to create a SQL log file to be able to monitor every change in the table with header and details.
The frond end is Access 2010
Also a easy way to be able to retrieve and lookup all info that was changed. (like Invoice or Order table)

Thank you in advance
LVL 1
frimyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dean ChafeeIT/InfoSec ManagerCommented:
Best way to do this is with a database trigger to monitor and log DDL events, with something like this:

USE [DDLtest]            
GO

/****** Object:  Table [dbo].[DDLEvents]    Script Date: 8/30/2016 3:01:00 PM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

IF (EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE  TABLE_NAME = 'DDLEvents'))
      Begin
            --Print 'Replacing table DDLEvents'
            --DROP TABLE DDLEvents
            RAISERROR ('Table DDLEvents EXISTS!, MUST DROP MANUAL',10, 1)  
            Goto EOJ  
      End


CREATE TABLE [dbo].[DDLEvents](
      [Eid] [int] IDENTITY(1,1) NOT NULL,
      [EventDate] [datetime] NOT NULL DEFAULT (getdate()),
      [EventType] [nvarchar](64) NULL,
      [EventDDL] [nvarchar](max) NULL,
      [EventXML] [xml] NULL,
      [DatabaseName] [nvarchar](255) NULL,
      [SchemaName] [nvarchar](255) NULL,
      [ObjectName] [nvarchar](255) NULL,
      [HostName] [varchar](64) NULL,
      [IPAddress] [varchar](32) NULL,
      [ProgramName] [nvarchar](255) NULL,
      [LoginName] [nvarchar](255) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

EOJ:
GO

/****** Object:  DdlTrigger [DDLTrigger]    Script Date: 3/24/2015 2:48:48 PM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TRIGGER [DDLTrigger_Procs]
    ON DATABASE
    FOR            CREATE_PROCEDURE, ALTER_PROCEDURE, DROP_PROCEDURE,
                  CREATE_VIEW, ALTER_VIEW, DROP_VIEW,
                  CREATE_FUNCTION, ALTER_FUNCTION, DROP_FUNCTION,
                  CREATE_TRIGGER, ALTER_TRIGGER, DROP_TRIGGER
AS
BEGIN
    SET NOCOUNT ON;
    DECLARE
        @EventData XML = EVENTDATA();
 
    INSERT  [dbo].[DDLEvents]
    (
        EventType,
        EventDDL,
        EventXML,
        DatabaseName,
        SchemaName,
        ObjectName,
        HostName,
        --IPAddress,
        ProgramName,
        LoginName
    )
    SELECT
        @EventData.value('(/EVENT_INSTANCE/EventType)[1]',   'NVARCHAR(100)'),
        @EventData.value('(/EVENT_INSTANCE/TSQLCommand)[1]', 'NVARCHAR(MAX)'),
        @EventData,
        DB_NAME(),
        @EventData.value('(/EVENT_INSTANCE/SchemaName)[1]',  'NVARCHAR(255)'),
        @EventData.value('(/EVENT_INSTANCE/ObjectName)[1]',  'NVARCHAR(255)'),
        HOST_NAME(),
      --  @ip,
        PROGRAM_NAME(),
        ORIGINAL_LOGIN();
END

GO

SET ANSI_NULLS OFF
GO

SET QUOTED_IDENTIFIER OFF
GO

ENABLE TRIGGER [DDLTrigger_Procs] ON DATABASE
GO
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
frimyAuthor Commented:
will try it thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
SQL

From novice to tech pro — start learning today.