Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sql-dmo running snapshot job ....

Status
Not open for further replies.

mooki

Programmer
Aug 1, 2000
32
IL
I have a code for running a snapshot job. It enters an endless loop. and i do not understand that loop part !
...
...
Set oJob = m_oSqlServer.JobServer.GetJobByID(sSnapshotJobID, True)

' ------------------------------------------------
' Activating the Snapshot Job
' ------------------------------------------------
With oJob
.Enabled = True
.JobSchedules(1).Schedule.FrequencySubDay = SQLDMOFreqSub_Once
.PurgeHistory
.Invoke
.Enabled = False
End With

'----------------------------
' Filtering History Messages
'----------------------------
Set oJobHistoryFilter = m_oSqlServer.JobServer.JobHistoryFilter

With oJobHistoryFilter
.JobID = sSnapshotJobID
.StartRunTime = oJob.LastRunTime
.StartRunDate = oJob.LastRunDate
.OldestFirst = False
End With

With oJob
Set oQueryResults = .EnumHistory(oJobHistoryFilter)

'++++++++++++++++++++++++++++++++
' FIRST UNKNOWN LOOP.....
'++++++++++++++++++++++++++++++++
Do While oQueryResults.Rows < 2
Pause 2000
Set oQueryResults = Nothing
Set oQueryResults = .EnumHistory(oJobHistoryFilter)
Loop

'++++++++++++++++++++++++++++++++
' SECOND LOOP.....
'++++++++++++++++++++++++++++++++

Do While Timer < start + vTimeOut And _
InStr(oQueryResults.GetColumnString(2, 8), &quot;1 article&quot;) = 0
Set oQueryResults = Nothing
Pause 20000
Set oQueryResults = .EnumHistory(oJobHistoryFilter)
Loop

End With



- IS THIS LAST 2 LOOPS IS IN PLACE ??
- CAN ANYONE UNDERSTAND THE NEED FOR THE FIRST LOOP ?
sometimes it get stuck over there with .rows=0 (once a day)
I DO UNDERSTAND THAT IM LOOKING FOR &quot;1 article was created&quot; IN THE SECOND LOOP....
WHAT IS THE WAY OF CHECKING IF THE JOB WAS EXECUTED AND DONE ???

Thanx,
Mooki
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top