Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Activex Job step Constants

Posted on 2004-08-12
7
Medium Priority
?
385 Views
Last Modified: 2008-02-01
I am running a step in a Server agent job that checks for the presence of a file. I want the step to fail if the file does not exist. Easy enough, but I CANNOT find the right constant to pass back to the SQL server agent to give the step a status of failure. Here is my script:
Function Main()
    Dim FileSys
    Dim strFileRoot
    Dim strISAFile
    Dim strToken
    Dim intCount
    Dim FileFound
       
    intCount = 1
    strISAFile = "ISA_IN.TXT"
    strToken = "token.txt"
    Set FileSys = CreateObject("Scripting.FileSystemObject")
    strFileRoot = "C:\isis\dbData\EDI_Admin\"
    FileFound = "False"

    Do While intCount < 500000 and FileFound = "False"
          If Not FileSys.FileExists(strFileRoot & strToken) Then
              intCount = intCount + 1
          Else
              FileFound = "True"            
          End If      
    Loop
                
    If FileFound = "False" Then      
       Main = DTSTaskExecResult_Failure
       Set FileSys = Nothing      
       Exit Function
    End If    

    If Not FileSys.FileExists(strFileRoot & strISAFile) Then
        Main = DTSTaskExecResult_Failure
        Set FileSys = Nothing
        Exit Function
    Else
        Main = DTSTaskExecResult_Success
    End If
    Set FileSys = Nothing
End Function

This was my first try, I know that  DTSTaskExecResult_Success is a datapump constant, but I have tried every job step constant I can find and all still report back success.
0
Comment
Question by:nwfisher
  • 3
  • 2
6 Comments
 
LVL 9

Expert Comment

by:SoftEng007
ID: 11795316
your task is fine. make sure you set your package to fail on first error.

package properties..logging.. fail package on first error.
this will send the error back to sql agent.
0
 

Author Comment

by:nwfisher
ID: 11795432
I actually figured this out about an hour ago. The tale goes like this. There is no way to send back a code from a server agent job step that will cause the step to be logged as "failed". The only way around this problem is to throw up a runtime error using Err.Raise. This script WAS NOT in a DTS package. It is a step in a SQL server agent job.
0
 
LVL 9

Expert Comment

by:SoftEng007
ID: 11797347
yep. good catch. ask for a points refund
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:nwfisher
ID: 11797357
This is my first question, how do I ask? If it's here, I'm asking.
0
 
LVL 9

Expert Comment

by:SoftEng007
ID: 11797418
I answered my question myself. What do I do?

 
Post a question in the Community Support topic area asking for a refund, and asking the Moderators to close the question. You'll be required to post your solution in your original question. A Moderator will post a notice of your request which will give the participants 96 hours to object to the refund. Note that if it resembles one of the suggested comments, the likelihood is that your request will not be granted, but rather, the points will be awarded to the Expert who makes the suggestion. In your Community Support request, remember to post a link to the original question.
 
0
 
LVL 1

Accepted Solution

by:
GhostMod earned 0 total points
ID: 12098323
PAQed, with points refunded (125)

GhostMod
Community Support Moderator
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question