serg2626
asked on
Automate SQL Query File
Hello,
I have an SQL 2005 Server and have a query which truncates my log files that I run manually whenever they get large in size. I would like to be able to save that query to a .sql file and have task scheduler run it every month or week on its own. How can I configure it so that I can use task scheduler to point to the .sql file and automatically run the query at a given date and time? I'm not sure how to get it to authenticate using a specific username and password etc. Please provide step by step instructions on doing this.
Thank you!
Sergio
I have an SQL 2005 Server and have a query which truncates my log files that I run manually whenever they get large in size. I would like to be able to save that query to a .sql file and have task scheduler run it every month or week on its own. How can I configure it so that I can use task scheduler to point to the .sql file and automatically run the query at a given date and time? I'm not sure how to get it to authenticate using a specific username and password etc. Please provide step by step instructions on doing this.
Thank you!
Sergio
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
What rrjegen17 suggested is a good practice. If disk space is a constraint for taking frequent log backups. And in case if you don not need point in time recovery. You can change recovery model to simple. But make sure you have full backups. I recommend this only if your database is not critical and if it is fine for you, if you can recovery last night backup.
Do you want to truncate a table that have log entries or to truncate the physical log file of a database?
Also, do you want to make a backup of the log/table before truncating it?
Regards,
Marco André