Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Automate using TSQL

Author  Topic 

jgrant
Yak Posting Veteran

69 Posts

Posted - 2007-03-15 : 13:47:25
I want to automate a query that I am running everyday. So, what I want to do is run it at a particular time of the day say 11:00pm. Is this possible? Should I create a stored procedure? And also, I want to run an update statement on a particular table on the first of every month. If anyone can give me some advice on this, I would appreciate it.

Jared

snSQL
Master Smack Fu Yak Hacker

1837 Posts

Posted - 2007-03-15 : 13:52:14
Create a scheduled job - the job can call a stored procedure or just run a batch of T-SQL so you can create a stored procedure, but it isn't necessary.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-03-15 : 14:00:42
Yes. Create a JOB and have SQL Server Agent handle it for you.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-03-15 : 14:01:32



Peter Larsson
Helsingborg, Sweden
Go to Top of Page

jgrant
Yak Posting Veteran

69 Posts

Posted - 2007-03-15 : 14:09:10
awesome. Also, if you guys have some free time, how can I check to see if the date is the first?
@getdate = getdate() then:
Go to Top of Page

snSQL
Master Smack Fu Yak Hacker

1837 Posts

Posted - 2007-03-15 : 14:17:47
When you create the job, just set the schedule to monthly and to run on the first of every month. You won't have to check the first of the month in your code.

If you do want to the first of the month in your code it will just be
day(getdate()) = 1
Go to Top of Page

jgrant
Yak Posting Veteran

69 Posts

Posted - 2007-03-15 : 14:33:14
Okay, this is off topic but I will say it anyway, whats up with the Yak?
Go to Top of Page

snSQL
Master Smack Fu Yak Hacker

1837 Posts

Posted - 2007-03-15 : 14:39:56
I have no idea when it started, but I guess someone figured calling people SQL gurus was soooo booooring
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-03-15 : 14:44:33
quote:
Originally posted by jgrant

Okay, this is off topic but I will say it anyway, whats up with the Yak?



http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=61012

Tara Kizer
http://weblogs.sqlteam.com/tarad/
Go to Top of Page
   

- Advertisement -