I am crafting a code generator for something, and I have encountered some things that I do not know yet. Excuse the scambled eggs in this code, but could you please tell me what a job is, and how to get it to run a stored procedure for me? I am trying to run a cron job which will run a loader application every n days.

<#@ parameter type="System.String" name="LoadName" #> <#@ parameter type="System.String" name="LoadTime" #> <#@ parameter type="System.String" name="SchemaName" #> <#
//generate header information
String description = "Schedule a cron job for the Loader to run periodically. ";
PLSQLHeader header = new PLSQLHeader(description, "INITIAL CODE");
#> <#= header.Draw() #>CREATE PROCEDURE <#= SchemaName #>.ScheduleJob() AS
BEGIN 
    USE msdb; 
    EXEC dbo.sp_add_job  
        @job_name = N'<#= loadName #>';  
    EXEC dbo.sp_add_schedule  
        @schedule_name = N'LoaderJobs',  
        @freq_type = 4,  
        @freq_interval = 1,  
        @active_start_time = <#= loadTime #>;
    EXEC sp_attach_schedule  
       @job_name = N'<#= loadName #>',  
       @schedule_name = N'RunOnce';  
    EXEC dbo.sp_add_jobserver  
        @job_name = N'<#= loadName #>'; 
END;
GO
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.