Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 601
  • Last Modified:

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?
0
meteorelec
Asked:
meteorelec
1 Solution
 
chapmandewCommented:
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

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now