Post by unknownGetting a spurious non-logged error for a dump tran command.
I would like to manually check to see if a dump tran can be
performed so I can monitor this condition. Is this a
condition I can check for in spt_values or logsegment status
bit? Would be part of the gen_id value or? Still searching
on my end. -Thanks.
On unix I use :
dbcc traceon (3604)
dbcc log (@dbid,0,0,0,-1,0,0)
Then I make a grep on 'time=' to get the very last transaction datetime, then I compare it with the previous one to see if there is a need to dump the transaction, it's a bit fishy but it works.
Here is the function in my ksh shell :
function GetLastTransDate
{
DBNAME=$1
LAST_TRANS=$($EXECDIR/sqsh -U$USERID -P$USER_PASS -S$EMS_SERVER -HHA -C"declare @dbid int select @dbid = db_id('$DBNAME') dbcc traceon (3604) dbcc log (@dbid,0,0,0,-1,0,0)" -b -h|grep "time=")
if [[ $LAST_TRAN == "" ]]
then #{
TRYVAR=1
while [[ $TRYVAR -le 5 && $LAST_TRANS == "" ]]
do #{
echo "retrying ...$TRYVAR/5"
sleep 5
LAST_TRANS=$($EXECDIR/sqsh -U$USERID -P$USER_PASS -S$EMS_SERVER -HHA -C"declare @dbid int select @dbid = db_id('$DBNAME') dbcc traceon (3604) dbcc log (@dbid,0,0,0,-1,0,0)" -b -h|grep "time=")
(( TRYVAR += 1 ))
done #}
fi #}
IFS="="
LAST_TRANS_DATE=$(echo $LAST_TRANS | awk '{print "",$4,$5,$6,$7 }')
IFS=" "
echo "LAST_TRANS=$LAST_TRANS"
echo "LAST_TRANS_DATE=$LAST_TRANS_DATE"
}