PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Hébergement serveur > ms.sqlserver.server > Calling a sql job synchronously
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Calling a sql job synchronously

Réponse
 
LinkBack Outils de la discussion
Vieux 27/03/2008, 19h56   #1
Clément Doss
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Calling a sql job synchronously

Hi,

My customer has a complex system that is made of jobs, procedures and scripts that
should run almost every day.
The problem is that sometimes, some job can run "a little longer" and theother
procedures and scripts (and even jobs) should wait for jobs to end beforestarting.

Is there a way to call a sql job synchronously from T-SQL, from a dll or from some
language? Are there any sample code?

TIA,
Clément
  Réponse avec citation
Vieux 27/03/2008, 20h03   #2
Aaron Bertrand [SQL Server MVP]
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Calling a sql job synchronously

No, jobs start asynchronously. You can have a bit in a table that gets
flipped to 1 when the job gets invoked (which only happens if the bit is
currently 0), and then flipped back upon successful completion.




"Clément Doss" <cdoss@nospam.dhs.com.br> wrote in message
news:%23iivexDkIHA.4396@TK2MSFTNGP04.phx.gbl...
Hi,

My customer has a complex system that is made of jobs, procedures and
scripts that
should run almost every day.
The problem is that sometimes, some job can run "a little longer" and the
other
procedures and scripts (and even jobs) should wait for jobs to end before
starting.

Is there a way to call a sql job synchronously from T-SQL, from a dll or
from some
language? Are there any sample code?

TIA,
Clément


  Réponse avec citation
Vieux 27/03/2008, 20h24   #3
Clément Doss
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Calling a sql job synchronously

Aaron Bertrand [SQL Server MVP] wrote:
> No, jobs start asynchronously. You can have a bit in a table that gets
> flipped to 1 when the job gets invoked (which only happens if the bit is
> currently 0), and then flipped back upon successful completion.
>


I could just check the job status every second. Not very "elegant" solution, but
something like:

startjob("JobName");
while checkjob("JobName")== __running__ {
sleep( 1000 ); // in ms
}
return checkjob("JobName")== __success__;


For optimal perfomance, is there a DLL I can use, or should I use T-SQL?

TIA,
Clément

  Réponse avec citation
Vieux 27/03/2008, 21h49   #4
TheSQLGuru
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Calling a sql job synchronously

You could also simply have each job in succession start the next job that is
supposed to fire as it's last step.

--
Kevin G. Boles
Indicium Resources, Inc.
SQL Server MVP
kgboles a earthlink dt net


"Aaron Bertrand [SQL Server MVP]" <ten.xoc@dnartreb.noraa> wrote in message
news:eh%23DT2DkIHA.2276@TK2MSFTNGP05.phx.gbl...
> No, jobs start asynchronously. You can have a bit in a table that gets
> flipped to 1 when the job gets invoked (which only happens if the bit is
> currently 0), and then flipped back upon successful completion.
>
>
>
>
> "Clément Doss" <cdoss@nospam.dhs.com.br> wrote in message
> news:%23iivexDkIHA.4396@TK2MSFTNGP04.phx.gbl...
> Hi,
>
> My customer has a complex system that is made of jobs, procedures and
> scripts that
> should run almost every day.
> The problem is that sometimes, some job can run "a little longer" and the
> other
> procedures and scripts (and even jobs) should wait for jobs to end before
> starting.
>
> Is there a way to call a sql job synchronously from T-SQL, from a dll or
> from some
> language? Are there any sample code?
>
> TIA,
> Clément
>



  Réponse avec citation
Vieux 27/03/2008, 23h36   #5
Aaron Bertrand [SQL Server MVP]
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Calling a sql job synchronously

>>
I could just check the job status every second.
>>


Ugh. If the job takes 20 minutes to run, then that is a LOT of wasted
resources. Why not update a flag somewhere only when the job has completed
(with a job you can mark this whether or not the originating step
succeeded)?

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 03h55.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,09936 seconds with 13 queries