Quantcast
Channel: SCN: Message List - SAP Adaptive Server Enterprise (SAP ASE) for Custom Applications
Viewing all articles
Browse latest Browse all 3587

Re: Last transaction time of the database

$
0
0

Provided that you can run this before running the ONLINE DATABASE command, dbcc log may work for you.

 

set switch on 3604

go

dbcc log(database_name, 0,0,0, -1, 30)

go

 

will print out the last "End Transaction" log record from the database, which

includes a datetime value of when that transaction ended.

(in the "-1"  parameter, being negative means to scan from the end of the log towards the front, i.e. showing the most recent record first, the 1 means just print out 1 record.  The "30" specifies the END_XACT log record type.)

 

As an example:

set switch on 3604

go

dbcc log(test, 0,0,0, -1, 30)

go

Switch 3604 ('print_output_to_client') is turned on.

All supplied switches are successfully turned on.

LOG SCAN DEFINITION:

        Database id : 7

        Log operation type ENDXACT (30)

        Backward scan: starting at end of log for 1 log records

        Maximum of 1 log records.

 

 

LOG RECORDS: (0 records did not qualify so far.)

 

 

        ENDXACT         (2704,7)        sessionid=2703,15

        attcnt=1 rno=7 op=30 padlen=4 len=32

        odc_stat=0x0000 (0x0000)

        loh_status: 0x0 (0x00000000)

        BEGINXACT=(2703,15) endstat=XEND_COMMIT time=Mar  2 2016 10:55:57:406AM

        xstat=0x0 []

 

 

 

 

Total number of log records 1 qualified out of 1 scanned.

DBCC execution completed. If DBCC printed error messages, contact a user with

System Administrator (SA) role.

 

Once you issue ONLINE DATABASE, new ENDXACT log records may be logged that now reflect current times rather than values from the dump.

 

Note that if there was no activity in the database this technique may show a date that occurred before the dump was taken - it just shows the time the last transaction ended.

 

-bret


Viewing all articles
Browse latest Browse all 3587

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>