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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

force error in stored procedure

Status
Not open for further replies.

anorthcote

Programmer
Sep 4, 2006
43
0
0
GB

I have two jobs running on my server that import data to my database. The first step of the first job writes a value to a table when it starts and removes that value when it ends correctly.

I need the second job to test if a value exists in the table and error if there is a value there.

So what I need help with is writing a stored procedure that I can run as step 1 of the job that I can force to error if a value exists so I can set the job to 'quit with failure' on failure of the step.

Does that make sense?

 
Yes that makes sense. This is done with the RAISERROR command (with only one E).

Code:
RAISERROR ('Your Message', 16, 1)
GO

Denny
MCSA (2003) / MCDBA (SQL 2000)
MCTS (SQL 2005 / Microsoft Windows SharePoint Services 3.0: Configuration / Microsoft Office SharePoint Server 2007: Configuration)
MCITP Database Administrator (SQL 2005) / Database Developer (SQL 2005)

My Blog
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top