I've just written my 1st stored procedure, I'm so proud
Its a housekeeping routine which I want to run once a week.
How do I go about scheduling stored procedures, through the windows scheduler on the server or something else?
In Enterprise Manager, goto Tools menu and pick Job Scheduling, pick T-SQL command select your database and enter "exec spYourProcedure" and continue throught the wizard.
This will create a job which you can see in EM under Management, SQL Server Agent, Jobs.
p.s. Make sure SQL Server Agent service is running or your job wont execute
ColinM, Please let me know how I can create a stored procedure with the following syntax:
USE Eng_Survey
EXEC sp_addumpdevice 'disk', 'Eng_Survey_backup_device', 'h:\sqldb_backup\Eng_Survey_backup.dat'
BACKUP DATABASE Eng_Survey TO Eng_Survey_backup_device WITH FORMAT
USE Eng_CE_Council
EXEC sp_addumpdevice 'disk', 'Eng_CE_Council_backup_device', 'h:\sqldb_backup\Eng_CE_Council_backup.dat'
BACKUP DATABASE Eng_CE_Council TO Eng_CE_Council_backup_device WITH FORMAT
------------------------------
I get an error saying that "a USE database statement is not allowed". Please advise if you can. Thanks!
As the mesage says, USE database is not permitted in a stored procedure. However, it is not necessary in order to create a backup device or backup the database. Terry L. Broadbent - DBA
Computing Links:
Colin posted his reply the same day that you posted the question. WildWest posted a new question on July 23 2002.
WildWest,
It is best to start a new thread and not use a year-old thread. In addition, it is best to post a question without requesting help from a specific member. There are many who can help. Terry L. Broadbent - DBA
Computing Links:
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.