473,396 Members | 1,726 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 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 2118
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.