SQL Jobs with Demo Example

 

 

What is a SQL Job?

A SQL Job is a feature in Microsoft SQL Server that allows you to automate the execution of one or more SQL scripts or other tasks on a scheduled basis or in response to specific events.

SQL Jobs are created using SQL Server Management Studio (SSMS) or Transact-SQL (T-SQL) scripts and can be scheduled to run at specific times or intervals, such as daily, weekly, or monthly. They can also be configured to run in response to events such as system startup, database backup completion, or the completion of another SQL job.

SQL Jobs can be used for a variety of purposes, such as database maintenance tasks, data integration, or report generation. They can be a valuable tool for improving the efficiency and consistency of your database management tasks. Some examples of SQL Jobs are automatic weekly backup, sending auto emails, newsletters, writing log files, and audit logs.

 

Create Database JobDB


Use JobDB

/*-=======================================

Create TableA ,TableB
Create Stored Procedure to Insert Data

 ================================*/

   select * from TableA


 --insert into tableA(Name,City) values('Rakesh Kumar','New Delhi')
 --insert into tableA(Name,City) values('Raj Kumar','Vanarash')
 --insert into tableA(Name,City) values('Shekar Kumar','Jammu & kahsmir')
 --insert into tableA(Name,City) values('Shakti Kumar','Deoghar')
 

 Create table TableA(
 Id Int identity(1,1),
 Name varchar(100),
 City varchar(100)
 )

  Create table TableB(
 Id Int identity(1,1),
 Name varchar(100),
 City varchar(100)
 )


 /*below job script to run */

 -- =============================================
-- Author:        <Author,,Name>
-- Create date: <Create Date,,>
-- Description:    <Description,,>
-- =============================================

CREATE PROCEDURE InsertData 

AS 

BEGIN
INSERT INTO [dbo].[TableB]

 ([Name] , [City])
SELECT 

Name,City
FROM TableA END 

GO

 

Exec  InsertData 


Below screen record please follow the steps to sql jobs










DOT NET ADDA

interested in solving the problems based on technologies like Amazon AWS ,Google Cloud, Azure and Dot related technology like asp.net, C#, asp.net core API, swagger, react js,Jquery ,javascripts, bootstrap, css,html, ms sql,IIS,WPF ,WCF,Firebase,RDLC Report etc..

1 Comments

Post a Comment
Previous Post Next Post