Download
100% FREE
Office Document APIs for .NET
Online: 851
Home
Articles
Interviews
Forums
For Beginners
Popular Questions
ITIL Career Advice
PMP Career Advice
Career Advices
Codes
Videos
ASP.NET
ASP.NET MVC
Android Intel XDK
Sql Server
AngularJS
Bootstrap
Backbone.JS
MongoDB
LESS (CSS)
jQuery
WPF
WWF
SSIS
LightSwitch
Tutorials
News
ASP.NET MVC
|
Be Interview Ready
|
Top Performers
|
DNF MVP
|
Top Posts
|
Winners
|
Subscribe
|
Bookmarks
|
Catalogs
Welcome Guest !
Register
Login
Home
>
Forums
>
Sql Server
>
Loading ...
Arhieve and Purge the Data
Posted by
Anonymus
under
Sql Server
on 8/27/2012 |
Points: 10
| Views : 896 | Status :
[Member]
| Replies : 2
Write New Post
|
Search Forums
|
Resolved Posts
|
Un Answered Posts
|
Forums Home
Hi,
I need to write a procedure to archieve and purge the data from a table older than 30days.
Could any one please help me on this?
Regards,
Anonymus
Reply
|
Reply with Attachment
Alert Moderator
Responses
Posted by:
Atal.Upadhyay
on: 8/27/2012
[Member]
Starter
|
Points: 25
0
First thing, you need to have timestamp field in the table to do so.
Second, you need to create a procedure or may be you can create Sql Job to run periodically like this.
CREATE PROCEDURE prc_clean_tables ()
BEGIN
BEGIN TRANSACTION;
DECLARE _now DATETIME;
SET _now := NOW();
INSERT
INTO Purge_Table
SELECT *
FROM MainTable
WHERE timestamp < _now - 30;
DELETE
FROM MainTable
WHERE timestamp < _now - 30;
COMMIT;
END
Anonymus
, if this helps please
login
to
Mark As Answer
. |
Alert Moderator
Posted by:
Anonymus
on: 8/28/2012
[Member]
Starter
|
Points: 25
0
Hi ,
Thanks for this.
Just one question. You said I need to create a store proc or a sql job...does this mean that I do not need a store procedure if i create a sql job.? Basically I will be creating a sql job that will be purging the data of 30 days older.
Also, my table does not have timestamp column.
Please guide me through....i am very new to all this...
Thank You...much appreciated..
Regards,
Anonymus
Anonymus
, if this helps please
login
to
Mark As Answer
. |
Alert Moderator
Login to post response
Latest Posts
Six s-e-a-t-e-r d.i.n.i.n.g table for sale Bradford UK
(0)
New
6 s.e.a.t.e.r d.i.n.i.n.g table for sale Swansea UK
(0)
New
D.e.s.i.g.n.e.r Jobs Edinburgh UK
(0)
New
Nepal Honeymoon Package
(0)
New
What to do when Adobe reader installation failed?
(0)
New
No 1 Nursing Essay Help Writing Service UK | Hire Experts Now
(1)
Updated
How to Find count Details Sql server
(0)
sharepoint installation system requirements
(0)
More ...