How Can I write A job in Ms SQL 2005

hamit yıldırım posted at 08-May-08 09:44

I want to worked a stored procedure periodacaly days or weekly

and it will work like a job

I was write in Oracle few times years ago

but I dont know in ms sql? How can I do

I look somethings like;

declare @rc = int,

@JobID uniqueidentifier

select @JobID = forjob

exec @rc = xxx.dbo.sp_add_jobschedule

@job_id = @forjob, -- ID of job you create the schedule for

@name = N'10 sec recurring', -- name of the schedule

@enabled = 1, -- enable the schedule for use

@freq_type = 4, -- daily frequency

@active_start_date = 20080508, -- date from which schedule will be active (July 6, 2003)

@active_start_time = 16, -- time from which schedule will be active (midnight)

@freq_interval = 1, -- unused for daily

@freq_subday_type = 2, -- seconds

@freq_subday_interval = 10, -- every 10 seconds

@freq_relative_interval = 0, -- unused for daily

@freq_recurrence_factor = 0, -- unused for daily

@active_end_date = 99991231, -- date which schedule becomes inactive (Dec. 31, 9999)

@active_end_time = 20080509 -- time which schedule becomes inactive (23:59:59)

if (@@error <> 0 or @rc <> 0) raiserror('Error creating job schedule', 1, 16)

 

USE msdb ;

GO

EXEC sp_add_jobstep

@job_name = N'forjob',

@step_name = N'Set database to read only',

@subsystem = N'TSQL',

@command = N'exec forjob',

@retry_attempts = 5,

@retry_interval = 5 ;

GO

 

if anyone help me pls..

Im headache in this problem and it is very important

Biography
The most likely way for the world to be destroyed, most experts agree, is by accident. That’s where we come in; we’re computer professionals. We cause accidents. Nathaniel Borenstein If the automobile had followed the same development as the computer, a Rolls‑Royce would today cost $100, get a million miles per gallon, and explode once a year killing everyone inside. Robert Cringely/InfoWorld To err is human‑‑and to blame it on a computer is even more so. Orben’s Current Comedy Copmuters are useless. They can only give you answers. Pablo Picasso Computers aren’t intelligent, they only think they are. The goal of Computer Science is to build something that will last at least until we’ve finished building it. Here we have a word meaning of straightforward it is that Hamit "delikanlı çocuk".. my best compliments.

Click here to sign in and reply. You could earn money via our $500 contest just for being helpful.
  How Can I write A job in Ms SQL 2005 - hamit yıldırım  08-May-08 09:44 9:44:40 AM
      IN SQL Management Studio Go to the SQL Server Agent - Peter Bromberg  08-May-08 10:11 10:11:01 AM
          sql acent - hamit yıldırım  08-May-08 10:43 10:43:57 AM
      add a job or scheduler - chakradhar koturu  08-May-08 09:40 9:40:05 PM
View Posts