Changing Schedules For A Job Outside SQL Server
Aug 31, 2006
Below is the script of a Job called "eFIMS_SendEmail" that I wish to
run. The intention is that every day of the week the job will execute
a SPROC at timed intervals. For example, the SundayRun schedule will
run once every 1 hours from 00:30:00 to 23:59:59
However, the clients have stated that they want an interface to this to
enable them easily to change the start time and frequency interval for
each day. It's an easy matter for me to paint them a form from within
the target application to enable the user to enter the start time and
interval for each day. I can then pass these as parameters to a SPROC.
How can I use these values to change the schedules for the job? For
example, if wanted to change SundayRun from once every 1 hours to once
every 30 mins? I know I could do it the hard way, by using string
manipulation (e.g. find string 'SundayRun', then look for the next
occurrence of @active_start_time, @freq_subday_type,
@freq_subday_interval etc. and do some replacement) but this seems
somewhat tricky.
Many thanks
Edward
-- Script generated on 8/31/2006 9:27 AM
-- By: sa
-- Server: BISMARK
BEGIN TRANSACTION
DECLARE @JobID BINARY(16)
DECLARE @ReturnCode INT
SELECT @ReturnCode = 0
IF (SELECT COUNT(*) FROM msdb.dbo.syscategories WHERE name =
N'[Uncategorized (Local)]') < 1
EXECUTE msdb.dbo.sp_add_category @name = N'[Uncategorized (Local)]'
-- Delete the job with the same name (if it exists)
SELECT @JobID = job_id
FROM msdb.dbo.sysjobs
WHERE (name = N'eFIMS_SendEmail')
IF (@JobID IS NOT NULL)
BEGIN
-- Check if the job is a multi-server job
IF (EXISTS (SELECT *
FROM msdb.dbo.sysjobservers
WHERE (job_id = @JobID) AND (server_id <0)))
BEGIN
-- There is, so abort the script
RAISERROR (N'Unable to import job ''eFIMS_SendEmail'' since there
is already a multi-server job with this name.', 16, 1)
GOTO QuitWithRollback
END
ELSE
-- Delete the [local] job
EXECUTE msdb.dbo.sp_delete_job @job_name = N'eFIMS_SendEmail'
SELECT @JobID = NULL
END
BEGIN
-- Add the job
EXECUTE @ReturnCode = msdb.dbo.sp_add_job @job_id = @JobID OUTPUT ,
@job_name = N'eFIMS_SendEmail', @owner_login_name = N'sa', @description
= N'No description available.', @category_name = N'[Uncategorized
(Local)]', @enabled = 0, @notify_level_email = 0, @notify_level_page =
0, @notify_level_netsend = 0, @notify_level_eventlog = 2,
@delete_level= 0
IF (@@ERROR <0 OR @ReturnCode <0) GOTO QuitWithRollback
-- Add the job steps
EXECUTE @ReturnCode = msdb.dbo.sp_add_jobstep @job_id = @JobID,
@step_id = 1, @step_name = N'SendEmail', @command = N'EXEC
stpSendEmailConfirmation', @database_name = N'194-eFIMS', @server =
N'', @database_user_name = N'', @subsystem = N'TSQL',
@cmdexec_success_code = 0, @flags = 4, @retry_attempts = 0,
@retry_interval = 1, @output_file_name = N'', @on_success_step_id = 0,
@on_success_action = 1, @on_fail_step_id = 0, @on_fail_action = 2
IF (@@ERROR <0 OR @ReturnCode <0) GOTO QuitWithRollback
EXECUTE @ReturnCode = msdb.dbo.sp_update_job @job_id = @JobID,
@start_step_id = 1
IF (@@ERROR <0 OR @ReturnCode <0) GOTO QuitWithRollback
-- Add the job schedules
EXECUTE @ReturnCode = msdb.dbo.sp_add_jobschedule @job_id = @JobID,
@name = N'SundayRun', @enabled = 1, @freq_type = 8, @active_start_date
= 20060831, @active_start_time = 3000, @freq_interval = 1,
@freq_subday_type = 8, @freq_subday_interval = 1,
@freq_relative_interval = 0, @freq_recurrence_factor = 1,
@active_end_date = 99991231, @active_end_time = 235959
IF (@@ERROR <0 OR @ReturnCode <0) GOTO QuitWithRollback
EXECUTE @ReturnCode = msdb.dbo.sp_add_jobschedule @job_id = @JobID,
@name = N'MondayRun', @enabled = 1, @freq_type = 8, @active_start_date
= 20060831, @active_start_time = 3000, @freq_interval = 2,
@freq_subday_type = 4, @freq_subday_interval = 30,
@freq_relative_interval = 0, @freq_recurrence_factor = 1,
@active_end_date = 99991231, @active_end_time = 235959
IF (@@ERROR <0 OR @ReturnCode <0) GOTO QuitWithRollback
EXECUTE @ReturnCode = msdb.dbo.sp_add_jobschedule @job_id = @JobID,
@name = N'TuesdayRun', @enabled = 1, @freq_type = 8, @active_start_date
= 20060831, @active_start_time = 4000, @freq_interval = 4,
@freq_subday_type = 4, @freq_subday_interval = 40,
@freq_relative_interval = 0, @freq_recurrence_factor = 1,
@active_end_date = 99991231, @active_end_time = 235959
IF (@@ERROR <0 OR @ReturnCode <0) GOTO QuitWithRollback
EXECUTE @ReturnCode = msdb.dbo.sp_add_jobschedule @job_id = @JobID,
@name = N'WednesdayRun', @enabled = 1, @freq_type = 8,
@active_start_date = 20060830, @active_start_time = 3000,
@freq_interval = 8, @freq_subday_type = 4, @freq_subday_interval = 30,
@freq_relative_interval = 0, @freq_recurrence_factor = 1,
@active_end_date = 99991231, @active_end_time = 235959
IF (@@ERROR <0 OR @ReturnCode <0) GOTO QuitWithRollback
EXECUTE @ReturnCode = msdb.dbo.sp_add_jobschedule @job_id = @JobID,
@name = N'ThursdayRun', @enabled = 1, @freq_type = 8,
@active_start_date = 20060831, @active_start_time = 3500,
@freq_interval = 16, @freq_subday_type = 4, @freq_subday_interval = 35,
@freq_relative_interval = 0, @freq_recurrence_factor = 1,
@active_end_date = 99991231, @active_end_time = 235959
IF (@@ERROR <0 OR @ReturnCode <0) GOTO QuitWithRollback
EXECUTE @ReturnCode = msdb.dbo.sp_add_jobschedule @job_id = @JobID,
@name = N'FridayRun', @enabled = 1, @freq_type = 8, @active_start_date
= 20060831, @active_start_time = 3000, @freq_interval = 32,
@freq_subday_type = 4, @freq_subday_interval = 30,
@freq_relative_interval = 0, @freq_recurrence_factor = 1,
@active_end_date = 99991231, @active_end_time = 235959
IF (@@ERROR <0 OR @ReturnCode <0) GOTO QuitWithRollback
EXECUTE @ReturnCode = msdb.dbo.sp_add_jobschedule @job_id = @JobID,
@name = N'SaturdayRun', @enabled = 1, @freq_type = 8,
@active_start_date = 20060831, @active_start_time = 0, @freq_interval =
64, @freq_subday_type = 8, @freq_subday_interval = 1,
@freq_relative_interval = 0, @freq_recurrence_factor = 1,
@active_end_date = 99991231, @active_end_time = 235959
IF (@@ERROR <0 OR @ReturnCode <0) GOTO QuitWithRollback
-- Add the Target Servers
EXECUTE @ReturnCode = msdb.dbo.sp_add_jobserver @job_id = @JobID,
@server_name = N'(local)'
IF (@@ERROR <0 OR @ReturnCode <0) GOTO QuitWithRollback
END
COMMIT TRANSACTION
GOTO EndSave
QuitWithRollback:
IF (@@TRANCOUNT 0) ROLLBACK TRANSACTION
EndSave:
View 1 Replies
ADVERTISEMENT
Jan 16, 2008
can any one tell me the sql server 2005job schedules,ssis packages
View 1 Replies
View Related
Jul 9, 2015
How would we know to assign the time stamps for automated backups in job schedules....
View 1 Replies
View Related
Sep 22, 2005
I'm having a problem figuring out how to show multiple event times in one string. The data I'm using is:
Code:
idloc_idtrny_dowtrny_time
17923:00:00 PM
18926:00:00 PM
19929:00:00 PM
201026:00:00 PM
211029:00:00 PM
221136:00:00 PM
231139:00:00 PM
23946:00:00 PM
If the Loc_ID and trny_dow is the same for mutiple rows, I need to concatenate the trny_time of those recoreds into a string and not return the individual times.
I can't figure out how to return the final recordset as:
Code:
loc_idtrny_dowtrny_time
923:00 PM & 6:00 PM & 9:00 PM
1026:00 PM & 9:00 PM
1136:00 PM & 9:00 PM
946:00 PM
Any help is much appreciated!
- Dan
View 1 Replies
View Related
Jan 25, 2007
Could anyone tell me how to create a scheduled job in sql server 2005, I have a bunch of queries thaty i want to run on a table and i want to automate it, does anyone know of any tutorials on the internet or any helpful links
Thanks
View 1 Replies
View Related
Apr 5, 1999
Whenever I set a schedule on any given package, it executes OK, but I'm not able to bring back those settings for review. Instead, it always starts with the blank schedule form. Any hints?
** Thanx in advance **
P.S. I log in NT as an Administrator.
View 1 Replies
View Related
May 12, 2004
I just created a job with more than one schedule. Specifically, one schedule for the 2nd Sunday and the other for the 4th Sunday. Has anyone ever created multiple schedules for a job?
Sidney Ives
Database Administrator
Sentara Healthcare
View 3 Replies
View Related
Jul 6, 2006
I have set up a DTS to import data from an Access database to a server which is running SQL. It works alright if I execute the DTS, but if I set it to run as a scheduled task, it tells me that the path to the access db is not valid, and that I should make sure the path name is spelled correctly and that I am connected to the server on which the file resides... so obviously it's not a spelling issue (since when I execute it, it works), but a security issue. Anyone have any ideas?
Thanks a lot,
Tex
View 9 Replies
View Related
Aug 27, 2007
I am looking for a script that will show me the job schedule for the jobs on a given server, in plain english. It would look something like this:
Job Name Schedule
Job 1 M,Tu,W,Th,F 3:10 pm
Job 2 1st Day Month 6:00 am
Job 3 Daily 4:15 pm
I have looked at the job schedule table and have decipher some of it, but not all. Can anyone point me in the right direction?
Thank you!!
Jim Youmans
St. Louis, Missouri, USA
View 4 Replies
View Related
Mar 28, 2014
I am doing some general housekeeping for a couple of our SQL boxes in the Development environment. All the databases are set to Simple recovery mode. No need in anything else for these boxes. I have a database on all the boxes named "DatabaseMaintenance" Keeps things like all the sprocs for any type of database maintenance, etc....
I would like to schedule a single sproc that is located in the DatabaseMaintenance database to shrink the Transaction logs on a set schedule. They sometimes grow quite large while testing and developing. The thing that I cannot seem to get around, is when using the ShrinkFile command, one must use the Log Name. If this code is in a sproc that is located in the DatabaseMaintenance database, it will fail when attempting to call out to a different database. Because the Log does not exist on the database that the sproc is located.
How can I get around this small dilemma? There are only about 10 databases per box. To a point we really do not care what happens to them. They are on a Full backup schedule daily, just to keep the objects. As I stated previously, the logs will still grow huge at times while pumping data.
Is there a way to create a piece of code that will run against each database on the server, and be stored in a single database? Other than the system databases of course.
View 5 Replies
View Related
Jun 12, 2015
I wanted to check with you all if it is possible to create a script which generates the list of the schedules of all the jobs and then analyses it to rearrange the job starttime to ensure that we have equal gap between two jobs starting time. Just to ensure we donot have many jobs running at the same time.
View 1 Replies
View Related
Feb 27, 2007
As best I can see, the new database maintenance tool allows you to set only one schedule as you work through the wizard. (For that matter if you put multiple tasks in the database, you can not fire them off individually on a different schedule.)
The solution is - of course - a different job for each task you want to have a specific schedule. Or design a database to control the workflow (possible, and arguably easier to maintain, but way too complicated, I think.)
Or perhaps I am missing something. So does anyone know of a better way to do that "All-in-one" kind of database maintenance - just like ti was in 2000?
View 1 Replies
View Related
Feb 6, 2007
Hi,
I have been trying to figure this out for a while. I have a report that should run at 9AM, 12 Noon and 2PM every weekday. Due to the complexity of the report, I'm using snapshots. Since the lowest gap is 2 hours, I currently have it configured to create the snapshot every two hours. Since this is running all day, my servers are taking a lot of strain. In the report manager help, it suggests creating three daily schedules for the report. I cannot find a way to create more than one schedule for a report. Please let me know how I can do this. Any help will be highly appreciated.
Thanks,
Anand
View 7 Replies
View Related
Jan 24, 2012
I have a copy of class schedules with only students that are taking half of a full year class in a separate table. The table lists the term that the students are taking so I joined that table to the actual class schedule table via the code below. The values are 1 & 2 and if it's null (not taking half of a full year class) it's a 9. So now I only need 9s and 2s to bell pulled from the script below. How do I go about doing that since HLF_Term is not a real column?
Code:
SELECT STUSCHEDULE.[School_Year]
,STUSCHEDULE.[School_Number]
,STUSCHEDULE.[Student_ID]
,STUSCHEDULE.[CourseID]
[Code] ....
View 4 Replies
View Related
Jan 30, 2008
Hi guys, just wanna hear your opinions on which would be better for maintenance plans.
Build separate schedules for each task (integrity checks, optimizations, backups)?
Or a single schedule for the entire plan?
Thanks!
Donn Policarpio
View 4 Replies
View Related
Apr 4, 2008
Hi All
what might be the result If schedules of the Job crashes in SQLServer 2000.
above scenario will going to happen in our Prod server for backup jobs, any pre-cautions I can take right now..
Help me.
View 8 Replies
View Related
May 8, 2014
I want to query my msdb job and jobschedule related tables to generate a list of runtimes for each of these jobs for the next day or any future date. This query should output JobID, Run_Date(YYYYMMDD), and Run_Time(HHMMSS).
If I have 3 jobs with...
Job#1 scheduled to run once every 4 hours between 6 AM and 10 PM
Job# 2 scheduled to run every 15 minutes between 11 AM and 1 PM
Job# 3 scheduled to run every minute between 4 PM and 4:15 PM
my output should look as below ....
View 1 Replies
View Related
May 26, 2015
I am trying to calculate how much revenue we may get, based on potential new business opportunities. The core fields we have are
Total Contract Value ($ or £)Duration of contract (months)Revenue start dateVarious information about the new business - ID, Title, Customer etc.
We can easily calculate the revenue per month with "Total Contract value divide by duration".
However what I would really like to do is be able to know how much revenue we will be getting each month.
To do this I was thinking we should probably create a new row for each month entry, with the mm-yyyy being the only difference for each row. But how to create the appropriate months and the correct amount of rows.
View 3 Replies
View Related
Jul 16, 2015
We are running into an issue where we are unable to run scheduled reports from SharePoint in the "Manage Shared Schedules" sections of any given site in our site collection (<site url>/_layouts/15/ReportServer/ScheduleList.aspx). Reports are able to be generated manually, but never run when scheduled from SharePoint.We are encountering the following error in the SharePoint logs for our server.
Microsoft.ReportingServices.Library.InvalidReportServerDatabaseException: , Microsoft.ReportingServices.Library.InvalidReportServerDatabaseException:
The version of the report server database is either in a format that is not valid, or it cannot be read. The found version is 'Unknown'. The expected version is '162'.; Here is the background in our environment:
SharePoint App Server - Server 2012 R2 running SharePoint 2013 Application server - running SSRS SharePoint Integrated configured through Central Admin.SharePoint SQL Server - Server 2012 R2 running SQL 2012 SP1 for the SharePoint farm - hosts the Reporting Services databases.I have run the script within the Central Admin > Provision Subscriptions and Alerts to give appropriate permissions the the account in use. Also the reporting services databases were created new as part of the install, so they were not migrated from a previous version.
View 3 Replies
View Related
Dec 7, 1999
Hi all,
I need to change the NT Server computer name (and the SQL Server name). I know how to do it in NT, but how would I go about changing the SQL Server name. Can anyone help me with this? Is this an easy process?
Thanks,
LC
View 3 Replies
View Related
Jan 29, 2004
Hi. Sorry to be asking this. I know there is a KB article with the steps for changing a SQL2K server name, but I can't find it for the life of me.
Anyone have it tagged?
TIA
View 3 Replies
View Related
Oct 8, 2015
We are going to install new SQL Server 2014 on Windows 2012 R2. There is a copy of this server which is running on SQL Server 2005. This one has old operating system and wont be able upgrade to SQL Server 2014.
After doing some checks on 2014 we would like to change this server-name with the old server-name which is running on 2005.how can we change the server-name?
View 4 Replies
View Related
Jun 17, 2008
Hi Experts,
Can someone help me in knowing what is the impact if I happens to change the name of the computer / name of the Server name.
Thanks in advance
View 1 Replies
View Related
Apr 22, 2007
Hi Guys,
I am using a MS SQL Server 2005 express edition for storing the meta-files of a b2b application.
The SQL 2005 is installed localy. Now I must change my server (machine) name cause a internal application need this action.
What is the best practice to do this?
I've got 2 databases and a lot of tabeles within the installed sql server.
I am happy for all tutorials or instructions to handle this proposal nearyl perfectyl.
Many Regards
View 1 Replies
View Related
Mar 15, 2001
I need to change the default collation of all dbs on all my servers to SQL_Latin1_General_CP1_CI_AI from SQL_Latin1_General_CP1_CI_AS. We need to do compares and sorts and want to ignore accents -- something that wasn't clear when we built the servers. I know this has to do with "re-building databases" -- maybe even including the master -- but I'm not certain exactly what this means. Thanks!
View 1 Replies
View Related
Oct 24, 2000
At work, we are in the process of moving a server running SQL Server 7 from one domain to another. A part of this domain change will necessitate that the server be renamed. In a couple of tests that we ran we found that changing the domain does not cause problems, but changing the server name does. How does one register the databases with the new server name without reinstalling everything from scratch?
Any assistance would be greatly appreciated as we are under a time crunch here. Please reply to my email as I am unable to check this board often.
Thanks,
Mike Sinnott
View 1 Replies
View Related
Nov 2, 1999
I have SQL ver 7.0 running on NT ver 4.0 sp5
I had to change the name of the server from server1 to server2
now I am Getting a message
"Your SQL server installation is either corrupt or has been tampered with (Unknown package id). Please rerun setup"
is there any other way besides rerunning setup ?
Thanks in Advance ??
Peter
View 2 Replies
View Related
Aug 19, 2002
We changed the TCP/IP address on on of our BDC's this weekend (also runs SQL 6.5). Now some of our client workstations are not able to connect to the database using TCP/IP. They can connect with named pipes, but it doesn't "stick" on a reboot. It goes back to connecting with tcp/ip. Some of the client workstations can connect with tcp/ip. Could someone help me with this? I'm confused. I can ping the server by name from the workstations and it resolves the tcp/ip address correctly.
View 2 Replies
View Related
Jul 23, 2005
Hello all,We are in the process of upgrading our SQL physical server (with SS2k). Inthe process we will change the OS form NT4 to W2K. What is the best way tocopy all my databases and SQL logins, roles, jobs, alerts, etc. from myactual (old) SQL Server to my new one?Thanks for your time.Yannick
View 2 Replies
View Related
Apr 13, 2006
Hi all,I've done some sniffing around but apart from one post in thisnewsgroup haven't been able to find much on this topic.We have recently moved (well, quite a while ago but that's by-the-by)from an NT domain to an AD domain. One of our SQL Servers is stilljoined to the NT domain and, since this domain is soon to bedecommissioned, I need to join this SQL Server to the AD domain.Is there anything I should be on the lookout for WRT this move?As far as I can see, the only thing this would cause an issue withwould be permissions for "logins" etc. This shouldn't be an issue asthe only logins on this SQL Server are either local or from WindowsAuthenticated from our AD domain.Any advice would be greatly appreciated.Many thanks,Ian
View 1 Replies
View Related
Jul 20, 2005
A server with SQL 2000 installed is moving to a new physical location. Ourcompany standards mean that the name of the server and the IP address of theserver will change also. This SQL instance name is the same as the servername. Will I have to uninstall and reinstall SQL Server (and recover thedatabases) when this move is made so that the instance name equals theserver name? Is there a stored procedure that changes the instance name tothe server name? Thank you.
View 1 Replies
View Related
Jul 3, 2007
Hi
Is it possible to change the name of a SQL Server instance on a server running multiple server instances? Or must the server be reinstalled?
Rgds
Bertrand
View 3 Replies
View Related
Mar 21, 2007
I would like to modify some of the properties of a ServerReport entity from a desktop app using the ReportViewer control. In particular, I would like to have the document map displayed as expanded, and make some changes to the group toggle items based on the user's parameter selection.
Can someone please point me in the right direction? How do I get access programmatically to the ServerReport layout?
Thx
View 2 Replies
View Related