dbTalk Databases Forums  

Add Job if not Exists?

microsoft.public.sqlserver.setup microsoft.public.sqlserver.setup


Discuss Add Job if not Exists? in the microsoft.public.sqlserver.setup forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
SnapDive
 
Posts: n/a

Default Add Job if not Exists? - 12-11-2009 , 12:09 PM






In T-SQL, I know how to add stored procs and tables if they do not
already exist. I am trying to figure out the right query for a job but
am not getting the syntax - can anyone show me what that is?

Thanks.

Reply With Quote
  #2  
Old   
Will Alber
 
Posts: n/a

Default Re: Add Job if not Exists? - 12-12-2009 , 12:50 AM






Try...

USE msdb

GO

IF NOT EXISTS(SELECT * FROM dbo.sysjobs WHERE name = '<job name>')

BEGIN

....

END



"SnapDive" <SnapDive (AT) community (DOT) nospam> wrote

Quote:
In T-SQL, I know how to add stored procs and tables if they do not
already exist. I am trying to figure out the right query for a job but
am not getting the syntax - can anyone show me what that is?

Thanks.


__________ Information from ESET NOD32 Antivirus, version of virus
signature database 4680 (20091211) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com





__________ Information from ESET NOD32 Antivirus, version of virus signature database 4680 (20091211) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.