Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

A created a new SQL Job in SQl Server Agent. I followed the steps mentioned in the article

Still it is in idle state. PLease note that the schedular is prepared to execute every 10 seconds.

Below is the Drop and create script

IF  EXISTS (SELECT job_id FROM msdb.dbo.sysjobs_view WHERE name = N'test')
EXEC msdb.dbo.sp_delete_job @job_id=N'7ac1e514-fec2-4516-b716-f00107fb127e', @delete_unused_schedule=1

SELECT @ReturnCode = 0
/****** Object:  JobCategory [[Uncategorized (Local)]]]    Script Date: 01/26/2012 14:22:27 ******/
IF NOT EXISTS (SELECT name FROM msdb.dbo.syscategories WHERE name=N'[Uncategorized (Local)]' AND category_class=1)
EXEC @ReturnCode = msdb.dbo.sp_add_category @class=N'JOB', @type=N'LOCAL', @name=N'[Uncategorized (Local)]'
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback


EXEC @ReturnCode =  msdb.dbo.sp_add_job @job_name=N'test', 
        @description=N'No description available.', 
        @category_name=N'[Uncategorized (Local)]', 
        @owner_login_name=N'sa', @job_id = @jobId OUTPUT
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
/****** Object:  Step [rr]    Script Date: 01/26/2012 14:22:31 ******/
EXEC @ReturnCode = msdb.dbo.sp_add_jobstep @job_id=@jobId, @step_name=N'rr', 
        @os_run_priority=0, @subsystem=N'TSQL', 
        @command=N'insert into [datet](dat) values(getdate())', 
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
EXEC @ReturnCode = msdb.dbo.sp_update_job @job_id = @jobId, @start_step_id = 1
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
EXEC @ReturnCode = msdb.dbo.sp_add_jobschedule @job_id=@jobId, @name=N's', 
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
EXEC @ReturnCode = msdb.dbo.sp_add_jobserver @job_id = @jobId, @server_name = N'(local)'
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
GOTO EndSave


enter image description here

share|improve this question

migrated from Jan 26 '12 at 11:58

This question came from our site for professional and enthusiast programmers.

The job will be idle unless it is actually running when you refresh the view in SSMS. What does the job history show (right-click the job, select "History")? – Ed Harper Jan 26 '12 at 8:19
not showing any record... – Helper Jan 26 '12 at 8:21
If the job isn't running, something is wrong with the schedule. I suggest you script out the job (right-click, select "script job as" > CREATE TO > New Query Editor window) and edit your question to include the resulting script. – Ed Harper Jan 26 '12 at 8:33
I have added the Drop/Create script as suggested by you. – Helper Jan 26 '12 at 8:50
Please update the question with the latest version of the job script – Ed Harper Jan 26 '12 at 16:17

As far as I can see your schedule is set to execute between midnight (12:00AM) to noon (12:00PM), i.e. your job will not execute in the afternoon and evening. Change your ending time to 11:59:59PM and it should run all day.

share|improve this answer

The job definition you have posted is configured only to execute between 20:32 and 21:59 in server local time. Check the local time of the server and confirm whether it's configured to be in the timezone you're expecting.

To remove this restriction, amend the schedule to run from 00:00:00 to 23:59:59.


Try changing the schedule end time from 12:00:00 PM to 11:59:59 PM, just to be certain about the time frame

share|improve this answer
Please check the schedule screenshot in my question. I hope it should be fine now ? – Helper Jan 26 '12 at 9:15
@StackOverflowUser - that looks correct. If you apply the change you'll soon be able to tell if the job is executing by monitoring the job history – Ed Harper Jan 26 '12 at 14:09
But i am still waiting to get a single record inserted in this table through the sql job scheduler – Helper Jan 26 '12 at 14:12
@StackOverflowUser - is job history being generated? – Ed Harper Jan 26 '12 at 16:03
no recordis coming up in history... – Helper Jan 26 '12 at 16:03

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.