Link to home
Start Free TrialLog in
Avatar of serg2626
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
Avatar of marcodelphi2010
marcodelphi2010
Flag of Brazil image

Hi,

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é
ASKER CERTIFIED SOLUTION
Avatar of Raja Jegan R
Raja Jegan R
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial


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.