Delete * from table, -i want this to run one everyday

I want run
Delete * from table,

once a day everyday, and i want to no what is the best way of automating this?
LVL 2
meteorelecAsked:
Who is Participating?
 
chapmandewConnect With a Mentor Commented:
Create a SQL AGent job and schedule that statement to run when you need it to run.
0
 
Aneesh RetnakaranDatabase AdministratorCommented:
if there are no relationships in this table, replace DELETE *  with a  "TRUNCATE TABLE tableName "  and create a job as Chap mentioned
0
 
AntonyDNCommented:
Use SQL Server Agent.

Start SQL Server Management Studio (or Query Analyser - It's pretty much the same, so far as I remember) and make sure you can see the Object Explorer (F8 if you can't) and Expand SQL Server Agent, which is at the bottom. Right click Jobs, choose New Job. Give it a name, then click Steps, click New..., name the step, and ensure the Type in the drop down is T-SQL, and the correct database is selected. Type your SQL in to the text box, and click OK.

Then select schedules, and create a new schedule, so it runs when you want.

That's it!

If you can't see SQL Server Agent in the  Object Explorer, you may need to start the service ...
Also, if you want to empty a table each day, it's better to use TRUNCATE TABLE [tablename]

Hope that helps
0
All Courses

From novice to tech pro — start learning today.