| Author |
Topic |
|
xhostx
Constraint Violating Yak Guru
277 Posts |
Posted - 2012-08-21 : 14:38:17
|
| I have a .SQL file that I want to run on a monthly basis.Is there anyway how to schedule this to happen?Thanks,--------------------------Joins are what RDBMS's do for a living |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-08-21 : 15:03:55
|
| you need to add a sql agent job and configure it to call and execute osql utility to execute th .sql file commands------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
xhostx
Constraint Violating Yak Guru
277 Posts |
Posted - 2012-08-21 : 15:11:56
|
| Sounds doable :).Do you have any example with step by step please :)Thanks Visakh!--------------------------Joins are what RDBMS's do for a living |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
xhostx
Constraint Violating Yak Guru
277 Posts |
Posted - 2012-08-22 : 08:34:53
|
Thanks Visakh,I'm running win2000 and tried multiple solution to automate that .SQL script but it does not RUN at all, here is what I have tried; 2 different solutions from Microsoft website:http://support.microsoft.com/kb/843282 Any help is appreciated!--------------------------Joins are what RDBMS's do for a living |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-08-22 : 11:05:29
|
| where are you creating the sql agent job? is sql file in same server or in a remote machine?also is it not runing at all or are you getting some error?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
xhostx
Constraint Violating Yak Guru
277 Posts |
Posted - 2012-08-22 : 11:17:31
|
| all files are in the same server.Following the steps of "Scheduled task" does show that the job (task) as "Running". However, my script should create/update text files which is not happening when right-click and run the task manually. However if I type this command in cmd "osql -E -ifile.sql -n" it does run and I can see the text files are being created/updated.Any help will very appreciated :)--------------------------Joins are what RDBMS's do for a living |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-08-22 : 11:22:01
|
| whats the account that sql server agent uses? does it have access to file path?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
xhostx
Constraint Violating Yak Guru
277 Posts |
Posted - 2012-08-22 : 13:08:55
|
The owner of the Job is part of the administrator.This is the error according to job history:Executed as user: XXDB1100\CompanyServices. Cannot open input file - C:\temp\folder\file.sql No such file or directory. Process Exit Code 1. The step failed. when I changed back the Owner to "sa", this wha tI got:The job failed. The Job was invoked by User sa. The last step to run was step 1 (SAudit). |
 |
|
|
|