SQL Server log file requests 

Introduction

This tool is accessible from any screen in the software once the database used is SQLServer™, using the Tools menu located at the top of the screen and which contains the following two choices :

SQLServer log file activation

This function makes it possible via the log file functionality under SQLServer to activate the events records for the database in a file, events that can then be analyzed.

Log file de-activation

This function launches the re-processing of the log file obtained by activation then displaying the result. This is used to view all the SQL actions executed during the activation.

Prerequisites

Authorization

The user must be authorized to use the debugger (DBG parameter).

Technical constraint

The function can only work if a process server is installed and is active on the database machine.

User Interface

When the function is used, a screen is used to enter a group of options :

Recover results

It is necessary to indicate what information is to be collected for the analysis.

The Standard option is used to recover the execution plans for the requests.

The Tuning option is used to recover the information on the SQL actions executed as well as the execution plans for the requests.

The user can also choose the events to be collected by means of the "Advanced events parameterization". The corresponding window will display all the possible options.

These events are grouped by type. For more information on the events see the SQLServer documentation, an extract is to be found in an annex to the document.

Sort options

By default the SQL commands are detailed in chronological order but it is possible to specify the sort options.

Several sort options are proposed and the first is the order corresponding to the highest cost according to the sort requested.

Presentation of the results

The user can choose to only list the first n records returned.

In the case where the user selects a sort, they will obtain the first n events passed on the database which corresponds to the most important element of this sort.

Using the log file obtained

The duration for the SQL actions (obtained for a "Completed" event) and the requests can be displayed.

Analysis of these actions makes it possible to establish whether the request is performing and if it uses the indexes.

it is not necessary to find the Table Scan

It is nor necessary to find the Constant Scan

When the use of an index (Index Seek) is found, it is necessary to use the maximum number of columns in the index (in the "SEEK" section).

Extract from the SQLServer documentation

This table displays the events that can be added or deleted from a log file.

Event number


Name of the event


Description

0-9

Reserved

 

10

RPC:Completed

Arises when a call to a remote procedure (RPC) is terminated.

11

RPC:Starting

Arises when a remote procedure call has started.

12

SQL:BatchCompleted

Arises when a Transact-SQL instruction batch is completed.

13

SQL:BatchStarting

Arises when a Transact-SQL instruction batch is started.

14

Login

Arises when a user succeeds in connecting to the SQLServer.

15

Logout

Arises when a user disconnects from the SQLServer.

16

Warning

Arises at the same time as the events warning, such as the client interruption requests or the client connection breaks.

17

ExistingConnection

Detect all the activities for the users connected to the SQLServer before starting the log file.

18

ServiceControl

Arises from the SQLServer services status is modified.

19

DTCTransaction

Transactions log file coordinated by Microsoft Distributed Transaction Coordinator (MS DTC) between two or more databases.

20

Login Failed

Indicate that an attempt to connect to the SQLServer from a client has failed.

21

EventLog

Indicate that the events have been entered in the Microsoft Windows NT® applications journal.

22

ErrorLog

Indicate that the error events are entered in the SQLServer errors journal.

23

Lock:Release

Indicate that a resource lock has been released for example a page.

24

Lock:Acquire

Indicate that a lock has been acquired on a resource, a data page for example.

25

Lock:Deadlock

Indicates that two concurrent transaction have generated a deadlock, one has attempted to obtain incompatible locks on the resources belonging to the other.

26

Lock:Cancelled

Indicate that the acquisition of a lock on a resource has been cancelled (for example because of a deadlock).

27

Lock:Timeout

Indicate that a lock request on a resource (for example a page) has exceeded the timeout because another transaction has a lock blocking the required resource. The timeout is determined by the @@LOCK_TIMEOUT function and can be defined with the use of the SET LOCK_TIMEOUT instruction help.

28

DOP Event

Occurs before the execution of an SELECT, INSERT or UPDATE instruction.

29-31

Reserved

Use the event 28 instead.

32

Reserved

 

33

Exception

Indicates that an exception has occurred in SQLServer.

34

SP:CacheMiss

Indicates that a stored procedure cannot be found in the procedure cache.

35

SP:CacheInsert

Indicates that an element is inserted in the procedure cache.

36

SP:CacheRemove

Indicates that an element is deleted from the procedure cache.

37

SP:Recompile

Indicates that a stored procedure has been recompiled.

38

SP:CacheHit

Indicates that a stored procedure is found in the procedure cache.

39

SP:ExecContextHit

Indicates when the execution version of a stored procedure has been found in the cache.

40

SQL:StmtStarting

Arises when the Transact-SQL instruction has started.

41

SQL:StmtCompleted

Arises at the end of the Transact-SQL instruction.

42

SP:Starting

Indicates that the stored procedure has started.

43

SP:Completed

Indicates that the stored procedure is complete.

44

Reserved

Use the event 40 instead.

45

Reserved

Use the event 41 instead.

46

Objetct:Created

Indicates that an object has been created, for example with the CREATE INDEX, CREATE TABLE and CREATE DATABASE instructions.

47

Object:Deleted

Indicates that an object has been deleted, for example with the DROP INDEX and DROP TABLE instructions.

48

Reserved

 

49

Reserved

 

50

SQL Transaction

Log the Transact-SQL BEGIN, COMMIT, SAVE and ROLLBACK TRANSACTION instructions.

51

Scan:Started

Indicates that a table or index analysis has started.

52

Scan:Stopped

Indicates that a table or index analysis is completed.

53

CursorOpen

Indicates that a cursor is open in a Transact-SQL by ODBC, OLE DB or DB-Library instruction.

54

Transaction Log

Log at the time the transactions are written in the transactions journal.

55

HashWarning

??Indicates that a hash option (hashed joint, hashed aggregation, hashed union, distinct hash) that is not in process on partition stamp changes to a rechange plan Because of the seriousness of the occurrence leads to a data discrepancy, log file indicators or bit counting.

56-57

Reserved

 

58

Auto Update Stats

Indicates that an automatic update of the index statistics has taken place.

59

Lock:Deadlock Chain

Produced for each event leading to the deadlock.

60

Lock:Escalation

Occurs when number of locks increases. Example : line lock increased or converted to a page lock.

61

OLE DB Errors

Indicates that an OLE DB error has occurred.

62-66

Reserved

 

67

ExecutionWarnings

Indicates that the warning messages occurred during the execution of a SQLServer stored procedure or instruction.

68

Execution Plan

Display the executed SQL instruction plan.

69

Sort Warnings

Indicates that the sort operations could not be carried out in memory. Doesn't include the sort operations containing the index creation, only the sort operations within a request (an ORDER BY clause in a SELECT command for example).

70

CursorPrepare

Indicates that a cursor in a Transact-SQL instruction is prepared for used by ODBC, OLE DB or DB-Library.

71

Prepare SQL

ODBC, OLE DB or DB-Library has prepared one or more instructions Transact-SQLinstructions to be used.

72

Exec Prepared SQL

ODBC, OLE DB or DB-Library has executed one or more Transact-SQL prepared instructions.

73

Unprepare SQL

ODBC, OLE DB or DB-Library has cancelled one or more Transact-SQL prepared instructions.

74

CursorExecute

A cursor previously prepared in a Transact-SQL by ODBC, OLE DB or DB-Library instruction is executed.

75

CursorRecompile

A cursor open in a Transact-SQL by ODBC or DB-Library instruction has been recompiled either directly or by a change to the structure.

Trigger for the ANSI and non-ANSI cursors.

76

CursorImplicitConversion

A cursor in a Transact-SQL instruction is converted by SQLServer from one type to another.

Trigger for the ANSI and non-ANSI cursors.

77

CursorUnprepare

A cursor prepared in a Transact-SQL instruction is cancelled by ODBC, OLE DB or DB-Library.

78

CursorClose

A cursor previously opened in a Transact-SQL by ODBC, OLE DB or DB-Library instruction is closed.

79

Missing Column Statistics

The column statistics that can be useful for optimization are not available.

80

Missing Join Predicate

A request without a join predicate is being executed. This can mean that the request takes a long time to execute.

81

Server Memory Change

The Microsoft SQLServer memory use has been increased or decrease, either by 1 MB, or 5% of the maximum memory size, according to which is the greater.

82-91

User Configurable (0 -9)

Event data defined by the user.

92

Data File Auto Grow

Indicates that a journal file has been automatically increased by the server.

93

Log File Auto Grow

Indicates that a journal file has been automatically increased by the server.

94

Data File Auto Shrink

Indicates that a data file has been automatically reduced by the server.

95

Log File Auto Shrink

Indicates that a journal file has been automatically reduced by the server.

96

Show Plan Text

Display the SQL instruction request plan from the request optimizer.

97

Show Plan ALL

Display the request plan with the complete details of the compilation of the SQL instruction currently in process.

98

Show Plan Statistics

Display the request plan with the complete details of the execution of the SQL instruction in process.

99

Reserved

 

100

RPC Output Parameter

Produce the output values for the parameters for all the RPC.

101

Reserved

 

102

Audit Statement GDR

Is produced each time that GRANT, DENY or REVOKE are sent by a user for an instruction authorization in SQLServer.

103

Audit Object GDR

Is produced each time that GRANT, DENY or REVOKE are sent by a user for a object authorization in SQLServer.

104

Audit Add/Drop Login

Arises when a SQLServer access connection is added or deleted ; for sp_addlogin and sp_droplogin.

105

Audit Login GDR

Arises when a Microsoft Windows® connection right is added or deleted ; sp_grantlogin, sp_revokelogin and sp_denylogin.

106

Audit Login Change Property

Arises when an access connection property, other than passwords, is modified; for sp_defaultdb and sp_defaultlanguage.

107

Audit Login Change Password

Arises when the password for a SQLServer access connection is modified.

The passwords are recorded.

108

Audit Add Login to Server Role

Arises when an access connection is added or deleted from a fixed server role ; for sp_addsrvrolemember and sp_dropsrvrolemember.

109

Audit Add DB User

Arises when an access connection is added or deleted in the form of a database user (Windows or SQLServer) for a database ; for sp_grantdbaccess, sp_revokedbaccess, sp_adduser and sp_dropuser.

110

Audit Add Member to DB

Arises when an access connection is added or deleted in the form of a database user (fixed or defined by the user) in a database ; for sp_addrolemember, sp_droprolemember and sp_changegroup.

111

Audit Add/Drop Role

Arises when an access connection is added or deleted in the form of a database user in a database ; for sp_addrole and sp_droprole.

112

App Role Pass Change

Arises when the password for an application role is modified.

113

Audit Statement Permission

Occurs when an instruction authorization (for example CREATE TABLE) is used.

114

Audit Object Permission

Occurs when an authorization object (for example SELECT) is used, whether successful or not.

115

Audit Backup/Restore

Occurs when a BACKUP or RESTORE command is issued.

116

Audit DBCC

Occurs when DBCC commands are issued.

117

Audit Change Audit

Occurs when audit log file modifications take place.

118

Audit Object Derived Permission

Occurs on the issue of CREATE, ALTER and DROP object commands.

Errors

In addition to the generic error messages, the following messages can appear during the entry :

"Error during the access to the database server"

The access to the database machine is not possible, there is no process server or it is not on-line.

"Access error for the database log file directory"

The directory indicated as the log file directory is not accessible.