SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


SQL Jobs help


SQL Jobs help

Author
Message
dean 62842
dean 62842
Forum Newbie
Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: General Forum Members
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
Nabha
Nabha
SSCommitted
SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)

Group: General Forum Members
Points: 1937 Visits: 1815
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!

---------------------------------------------------------------------------------
Fraggle-805517
Fraggle-805517
SSCrazy
SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)

Group: General Forum Members
Points: 2413 Visits: 1512
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
dean 62842
dean 62842
Forum Newbie
Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: General Forum Members
Points: 5 Visits: 14
Wow guys!
Thanks to both for the very prompt reply.
This has given me exactly what I needed.

Thank You
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search