I want to create a JOB in SQL Server 2012, to execute two related stored procedures.
If I create the JOB like above, the second one start the execution after the first one completed, or both the Queries Executed simultaneously?
Help me to find it. Thanks in advice.
T-SQL is a scripting language. The statements are executed sequentially. In fact, this is true of almost all computer languages. Usually, you have to go through some effort to execute things in parallel.
If the first statement fails, then the second statement is not executed.
SQL Server does have mechanisms for running things in parallel. One method is rather complicated, using the message queue functionality. You can read about message queuing here. Or there are various blogs on the subject of asynchronous execution, such as this one.
Another option is to use jobs. Simply schedule two jobs to run at the same time.
You create one Store procedure for call two procedure and call from job. Both SP is execution within new job1 SP even fail one or success.
create procedure job1 as begin try begin try exec my_First_Procedure; end try begin catch select ERROR_MESSAGE() as messages; end catch begin try exec my_Second_Procedure; end try begin catch select ERROR_MESSAGE() as messages; end catch select 'Success' as messages; end try begin catch select ERROR_MESSAGE() as messages; end catch