SQL Server DBA Tutorial 30 - How to Create Job using SQL Server Agent

preview_player
Показать описание
*****************************************************************************************
* How to Create Job using SQL Server Agent *
*****************************************************************************************

SQL Server Agent is a component of Microsoft SQL Server which schedules jobs and handles other automated tasks. It runs as a Windows service so it can start automatically when the system boots or it can be started manually.

We will be using two ways in SQL Server
1. Using SQL Server management studio graphic user interface GUI Version
2. Using T-SQL script

1- Job Parameters
2- Step Parameters
3- Job History Options

/***T-SQL script***/
USE [msdb]

GO

DECLARE @jobId BINARY(16)

@job_name=N'Test',
@enabled=1,
@notify_level_eventlog=0,
@notify_level_email=2,
@notify_level_netsend=2,
@notify_level_page=2,
@delete_level=0,
@category_name=N'[Uncategorized (Local)]',
@owner_login_name=N'sa',
@job_id = @jobId OUTPUT

SELECT @jobId

GO

@job_name=N'Test',
@server_name = N'CHIRAG-LAPPY'

GO

USE [msdb]

GO

@job_name=N'Test',
@step_name=N'AllDatabaseView',
@step_id=1,
@cmdexec_success_code=0,
@on_success_action=1,
@on_fail_action=2,
@retry_attempts=0,
@retry_interval=0,
@os_run_priority=0,
@subsystem=N'TSQL',
@database_name=N'master',
@output_file_name=N'C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Backup',
@flags=2

GO

USE [msdb]

GO

@job_name=N'Test',
@enabled=1,
@start_step_id=1,
@notify_level_eventlog=0,
@notify_level_email=2,
@notify_level_netsend=2,
@notify_level_page=2,
@delete_level=0,
@description=N'',
@category_name=N'[Uncategorized (Local)]',
@owner_login_name=N'sa',
@notify_email_operator_name=N'',
@notify_netsend_operator_name=N'',
@notify_page_operator_name=N''

GO

Note : Flow the Process shown in video.

😉Subscribe and like for more videos:
💛Don't forget to, 💘Follow, 💝Like, 💖Share 💙&, Comment

Tutorial Link :

Thanks & Regards,
Chitt Ranjan Mahto "Chirag"
_________________________________________________________________________________________
Note: All scripts used in this demo will be available in our website.
Link will be available in description.
Рекомендации по теме
join shbcf.ru