Solved

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

Posted on 2008-06-18
3
593 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
sql join/ assign small # first 10 83
Oracle - Query Insert and Update multiple tables 5 58
SQL Error in WHERE Clause 5 42
SQL Query resolving a string conversion issue 26 39
Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

867 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

19 Experts available now in Live!

Get 1:1 Help Now