Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to create Job Schedule using T-SQL script (not SQL Server Agent schedule creation wizard)?

I have to create a script which will execute at scheduled times. Because my client is not familiar with SQL Server, I would like to create a schedule on my machine as per my client's requirements using SQL Server Agent schedule creation wizard, then create a script of the created schedule (which I will send to the client).

How can I create a T-SQL Job Schedule without using the SQL Server Agent schedule creation wizard?

like image 554
imdadhusen Avatar asked Jul 14 '11 05:07

imdadhusen


People also ask

How do I create a scheduled job in SQL?

Expand SQL Server Agent, expand Jobs, right-click the job you want to schedule, and click Properties. Select the Schedules page, and then click New. In the Name box, type a name for the new schedule. Clear the Enabled check box if you do not want the schedule to take effect immediately following its creation.

How do you script a job in SQL Server?

Click on any job in the Object Explorer window and a list of all the agent jobs appears in the 'Object Explorer Details' window. Select all the jobs you want to script (press the Ctrl button while clicking to select individual jobs) and then right click and select the scripting option you want.

Who can create jobs in SQL Server?

To create a job, a user must be a member of one of the SQL Server Agent fixed database roles or the sysadmin fixed server role. A job can be edited only by its owner or members of the sysadmin role.

Does SQL Server have a scheduler?

A scheduler can be described as a piece of software that coordinates the execution of different processes and administers its available resources. SQL Server has its own scheduling mechanism that is implemented in what we know as SQLOS.


1 Answers

You can use management studio to get the creation script.

Create the job in management studio

Then right click the job and from the floating menu select Script The Job As -> Create To -> New Query Editor Window.

Alter the script details to match your needs

like image 87
niktrs Avatar answered Oct 06 '22 00:10

niktrs