472,993 Members | 2,732 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,993 software developers and data experts.

About deleting old files from a folder

Zerin
64
Hi guys,

I started "autopurging" discussion many days ago.As I couldn't do it,so I decided to change my database into SQL Server.And so posted this problem here.

Plain and simple ------ I have a database named TANI and it has a table named "TANI" as well.

Table TANI has 3 fields only ------
1. CSV FILES that holds a link to some csv files from a folder
2. IMAGE FILES that holds a link to some image files from a folder
3. DATE that records the time of data arrival in the database.

Now, I just want to delete files ( both csv and image files ) from the folder INSPECTION that are 1 month old by using SQL Server triggers.

Can anyone help me this time?

Zerin
Jan 10 '07 #1
6 2110
iburyak
1,017 Expert 512MB
Try this. Just test it first.

[PHP]
CREATE TRIGGER tIUD_machine ON machine
FOR INSERT, UPDATE,DELETE
AS
BEGIN
DELETE FROM INSPECTION
FROM INSPECTION I
JOIN TANI T ON I.[CSV FILES] = T.[CSV FILES]
AND I.[IMAGE FILES] = T.[IMAGE FILES]
WHERE DATE < dateadd(m,-1,getdate())

END [/PHP]
Jan 10 '07 #2
Zerin
64
Try this. Just test it first.

[PHP]
CREATE TRIGGER tIUD_machine ON machine
FOR INSERT, UPDATE,DELETE
AS
BEGIN
DELETE FROM INSPECTION
FROM INSPECTION I
JOIN TANI T ON I.[CSV FILES] = T.[CSV FILES]
AND I.[IMAGE FILES] = T.[IMAGE FILES]
WHERE DATE < dateadd(m,-1,getdate())

END [/PHP]

Dear iburyak ,

Thanks for the reply.Testing now.And 'll let u know.

Zerin
Jan 11 '07 #3
Zerin
64
Try this. Just test it first.

[PHP]
CREATE TRIGGER tIUD_machine ON machine
FOR INSERT, UPDATE,DELETE
AS
BEGIN
DELETE FROM INSPECTION
FROM INSPECTION I
JOIN TANI T ON I.[CSV FILES] = T.[CSV FILES]
AND I.[IMAGE FILES] = T.[IMAGE FILES]
WHERE DATE < dateadd(m,-1,getdate())

END [/PHP]

Dear iburyak ,

I tried the trigger and it gives the following error message:

Object 'machine' does not exist or is invalid for this operation.

Actually,I'm not expert in SQL Server.So,I can't understand what to do.MSDN search also don't have any fruitful reply.Please help !

Zerin
Jan 11 '07 #4
iburyak
1,017 Expert 512MB
Sorry, I just wrote table name that I have in my database you had to replace it with your test table name.

You have to change this line.


[PHP]CREATE TRIGGER tIUD_table_name ON table_name_here[/PHP]


tIUD_table_name - trigger name

table_name_here - should be a table name you creating trigger over.

Good Luck.
Jan 11 '07 #5
Zerin
64
Oh !

What a foolish buddy am I ! I should'v noticed that. Thank u iburyak. Think it'll work now. Many many thanks frnd.

Zerin
Jan 12 '07 #6
Zerin
64
Dear iburyak ,

It worked with a few change and I could do it by VB 2005 also.Ah! Relax.....................
Jan 15 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: georgios zakitraxis | last post by:
Hi all, I have a folder with many pictures in it. All have the name like: HHMMDDMMYYYY.jpg H-hour M-minute D-day M-month Y-year
5
by: Rosa | last post by:
Hi, I'm trying to clear the TIF on Windows XP programmatically with the below code. This code works fine on any folder but the TIF. For some reason the atEnd() statements always defaults to true...
13
by: Bob Darlington | last post by:
I have a repair and backup database routine which runs when a user closes down my application. It works fine in my development machine, but breaks on a client's at the following line: If...
6
by: Martin Bischoff | last post by:
Hi, I'm creating temporary directories in my web app (e.g. ~/data/temp/temp123) to allow users to upload files. When I later delete these directories (from the code behind), the application...
5
by: Sandeep Singh Sekhon | last post by:
I am Developing a Web Application with ASP.NET 1.1 I have one project Folder which is virtual directory of IIS. In this directory, I have one Folder named Photos in which I used to Store Photos....
5
by: jawloc | last post by:
Hi I have a question that I hope someone can help me with. I have created a web page that allows a user to upload an image with a caption to my web server. Here is what happens when the user...
0
by: rahuldhammy | last post by:
I am implementing a personalization(customizing the contents of the web site according to the user choice)in asp.net web site.For this i have to delete modify some files in my App_Themes folder.I am...
1
by: =?Utf-8?B?TWFyZWs=?= | last post by:
Hi Sorry for the newbie question, but is it possible to stop the publish operation from Visual Studio 2005 deleting files in a specific folder on the web server? I have an uploads folder on the...
9
by: divyakgowda | last post by:
Hello, For my ruby on rails application,i need to delete all the temporary files created in /tmp folder.If those files increases, at some point in time, my application stops working unless i...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.