Solved

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

Posted on 2008-06-18
3
592 Views
Last Modified: 2012-05-05
I want run
Delete * from table,

once a day everyday, and i want to no what is the best way of automating this?
0
Comment
Question by:meteorelec
3 Comments
 
LVL 60

Accepted Solution

by:
chapmandew earned 500 total points
ID: 21812585
Create a SQL AGent job and schedule that statement to run when you need it to run.
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 21812630
if there are no relationships in this table, replace DELETE *  with a  "TRUNCATE TABLE tableName "  and create a job as Chap mentioned
0
 
LVL 2

Expert Comment

by:AntonyDN
ID: 21812669
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
indexed table vs unindexed table 19 62
How to use TOP 1 in a T-SQL sub-query? 14 33
query help 18 52
SQL Query to display duplicates ? 6 27
Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now