471,089 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,089 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 1957
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

Post your reply

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

Similar topics

7 posts views Thread by georgios zakitraxis | last post: by
13 posts views Thread by Bob Darlington | last post: by
6 posts views Thread by Martin Bischoff | last post: by
5 posts views Thread by Sandeep Singh Sekhon | last post: by
5 posts views Thread by jawloc | last post: by
1 post views Thread by =?Utf-8?B?TWFyZWs=?= | last post: by

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.