[email protected] Chirag's SQL Server DBA Tutorial https://www.chirags.in
*****************************************************************************************
* 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)
EXEC msdb.dbo.Sp_add_job
@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
EXEC msdb.dbo.Sp_add_jobserver
@job_name=N'Test',
@server_name = N'CHIRAG-LAPPY'
GO
USE [msdb]
GO
EXEC msdb.dbo.Sp_add_jobstep
@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',
@command=N'select * from sys.databases',
@database_name=N'master',
@output_file_name=N'C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Backup',
@flags=2
GO
USE [msdb]
GO
EXEC msdb.dbo.Sp_update_job
@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:
/ @chiragstutorial
💛Don't forget to, 💘Follow, 💝Like, 💖Share 💙&, Comment
Tutorial Link :
https://www.gyans.in/tutorials/micros...
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.
Watch video SQL Server DBA Tutorial 30 - How to Create Job using SQL Server Agent online without registration, duration hours minute second in high quality. This video was added by user Chirags Tutorial 12 June 2022, don't forget to share it with your friends and acquaintances, it has been viewed on our site 119 once and liked it 3 people.