[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.0

How do I force a raiserror in a job step to immediately stop the currently running step?

Asked by tf842 in MS SQL Server

Tags: job, force, sql, failure, raiserror

sql svr 2k

I want the job step to stop immediately if either of the if statements are true.

I have the following step code:
declare @retval int
declare @job_name varchar(128)
declare @job_name_for_reschedule varchar(128)
declare @job_id uniqueidentifier
declare @schedule_name varchar(128)

select @job_name_for_reschedule = 'STG_DataPush_Stuff'
select @schedule_name = 'Reset After Failure'

EXECUTE @retval = sp_verify_job_identifiers '@job_name',
                                                '@job_id',
                                                 @job_name_for_reschedule OUTPUT,
                                                 @job_id   OUTPUT

--IF @retval <> 0 Raise an error
declare @intMins_To_Add int
declare @dtStart_Time smalldatetime
declare @intNew_Active_Start_Date int
declare @chrNew_Active_Start_Time varchar(19)
declare @intNew_Active_Start_Time int

select @intMins_To_Add = 10

select @dtStart_Time = dateadd(minute,@intMins_To_Add,getdate())

/****************************************************************************************************************/
/************** If either of the following 2 if statements are true, I want the step to fail and stop immediately. it seems to continue running *********/
/****************************************************************************************************************/
--Raise error if reschedule time is after 7:58am
if (SELECT DATEPART(hh, @dtStart_Time)) >= 8
  begin
    raisError ('Cannot reschedule for after 8:00 am',11,1,'Too Late to Reschedule')  
  end

if (SELECT DATEPART(hh, @dtStart_Time)) = 7
  begin
    if (SELECT DATEPART(mi, @dtStart_Time)) > 58
      begin
        raisError ('Cannot reschedule for after 7:58 am',11,1,'Too Late to Reschedule')  
      end
  end

SELECT @intNew_Active_Start_Date = Convert(varchar(8), @dtStart_Time, 112)
select @chrNew_Active_Start_Time = convert(varchar(19), @dtStart_Time,120)
select @chrNew_Active_Start_Time = right(@chrNew_Active_Start_Time, 8)
select @chrNew_Active_Start_Time = left(@chrNew_Active_Start_Time, 2) + substring(@chrNew_Active_Start_Time,4,2) + right(@chrNew_Active_Start_Time, 2)
select @intNew_Active_Start_Time = @chrNew_Active_Start_Time

EXEC sp_update_jobschedule @job_name = @job_name_for_reschedule, @name = @schedule_name,
    @Active_Start_Date = @intNew_Active_Start_Date, @Active_Start_Time = @intNew_Active_Start_Time, @enabled = 1
[+][-]01/19/07 02:25 PM, ID: 18353055Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: MS SQL Server
Tags: job, force, sql, failure, raiserror
Sign Up Now!
Solution Provided By: angelIII
Participating Experts: 2
Solution Grade: A
 
[+][-]01/19/07 02:05 PM, ID: 18352966Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/19/07 02:09 PM, ID: 18352987Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01/19/07 02:45 PM, ID: 18353160Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]03/20/07 09:30 PM, ID: 18761788Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]03/25/07 07:21 PM, ID: 18790383Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]03/26/07 07:05 AM, ID: 18792825Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92