inchirags@gmail.com 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.
In questa pagina del sito puoi guardare il video online SQL Server DBA Tutorial 30 - How to Create Job using SQL Server Agent della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Chirags Tutorial 12 giugno 2022, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 119 volte e gli è piaciuto 3 spettatori. Buona visione!