Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
laddu
Constraint Violating Yak Guru
332 Posts |
Posted - 2013-11-19 : 15:19:07
|
we have a SQL Server agent job which has 2 stepsstep 1- type is SSIS package it will fix the sync issues between OLTP and Reporting DB. Basically it is a ETL jobStep 2- send error email via sp_send_dbmail incase of job failure. added t-sql script Now I want to add a step first...the step is - query data from a table if it returns NO rows then go to next stepif returns rows donot go to next stepselect * from table1 where CoulmnID ='' --Ensure it returns no rows.HOW to add this step to job? any thoughts? thanks |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2013-11-19 : 15:20:12
|
Use the RAISERROR command to raise an error when it returns data:IF EXISTS (select ...)RAISERRORThen have the job step quit the job on failure of that step.Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-11-20 : 02:13:22
|
Actually you could do it all within same SSIS package itself. Thats the purpose of control flow engine. you can use SentMail task and link to your current sync step on failure to send error mail in case of failure. you can also add execute sql task to check count of rows and based on count determine next task to be executed by using expression based precedence constraint. So you'll just have single step in sql job and you do all control sequence action inside control flow of the package.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|