Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

SQL Jobs help Expand / Collapse
Author
Message
Posted Tuesday, January 26, 2010 2:20 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, January 3, 2011 10:31 AM
Points: 5, Visits: 14
I want to write a scheduled job for my database to run every night.

Essentially I need the job to match todays date in the database and then add 1500 to an existing number in the results table.

Is a job the correct way to go about this? If so how to do?

There's is lot's of tutorials on setting up the job and schedule, but not so much help on the writing the procedures within.
I'm not a newbie with regards to stored procedures, but definitely new to jobs.

Helps please.

thanks
Post #853971
Posted Tuesday, January 26, 2010 9:12 PM


Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Tuesday, August 2, 2011 3:36 AM
Points: 579, Visits: 1,803
dean 62842 (1/26/2010)
I want to write a scheduled job for my database to run every night.

Essentially I need the job to match todays date in the database and then add 1500 to an existing number in the results table.

Is a job the correct way to go about this? If so how to do?


I am not sure if there is any better way of doing it. THere could be.. lets wait and see if someone has a better idea.

There's is lot's of tutorials on setting up the job and schedule, but not so much help on the writing the procedures within.
I'm not a newbie with regards to stored procedures, but definitely new to jobs.


Jobs -> New Job -> enter general details -> Go to steps tab -> Click on 'New' -> Enter the step Name -> Select type as 'Transact -SQL script (T-SQL)' -> Select the database -> just Enter the sp name in the command window -> parse -> ok->Schedules -> enter schedules-> ok

Your stored procedure would contain the code along these lines..

UPDATE UT
SET sale = Sale + 1500 -- Select *
FROM ABC UT
WHERE dateadd(dd, 0, Datediff(dd, 0, date1)) =
dateadd(dd, 0, Datediff(dd, 0, Getdate()))

hope this helps!


---------------------------------------------------------------------------------
Post #854099
Posted Tuesday, January 26, 2010 9:30 PM
Right there with Babe

Right there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with Babe

Group: General Forum Members
Last Login: Today @ 12:44 PM
Points: 727, Visits: 1,409
A job is the easiest way to do it, but not the only way. You could setup a service broker queue to run the proc every night at the same time. You could setup an infinite loop proc that only executes the stores procedure when you want it.

However, for what you are looking for, a job is probably the easiest and most efficient way to do it.

Nabha hit the nail on the head for the rest of it.

Fraggle
Post #854112
Posted Wednesday, January 27, 2010 6:58 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, January 3, 2011 10:31 AM
Points: 5, Visits: 14
Wow guys!
Thanks to both for the very prompt reply.
This has given me exactly what I needed.

Thank You
Post #854350
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse