• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 229
  • Last Modified:

How to alter job execution in sql server using tsql

I want to alter the execution (pass/fail) of a job based on tsql results.  Very simply, I want to create a job that will fail, and send a notification message, if a date in a table is not = to today.

I can create a stored procedure, but how to maje job fail based on results?

BTW:  I am using SQL Server 2005 Workgroup.
0
No1Coder
Asked:
No1Coder
1 Solution
 
BrandonGalderisiCommented:
Create a job that executes TSQL like so.  It will fail if the date is not = today.

If not exists (select 1 from dbo.SomeTable where SomeDate = dateadd(d, datediff(d, 0, getdate()),0))
   raiserror('FailJob',16,1)
0
 
No1CoderAuthor Commented:
Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now