Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Auto Delete

Author  Topic 

Mjolnir
Starting Member

12 Posts

Posted - 2008-03-09 : 08:53:51
Hi,

I want to delete automatically all the fridays 11 Pm the complete content of my table.

How do I to do this?

Sorry my stupid question but I dont have idea how to do this.

Mjolnir.

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2008-03-09 : 09:05:22
set a scheduled job to do this.

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com
Go to Top of Page

Mjolnir
Starting Member

12 Posts

Posted - 2008-03-09 : 09:10:47
Can I with a scheduled job set a query by condition?

Delete * from Table where register_date < getdate(); ?

Thanks.

Mjolnir.

Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2008-03-09 : 09:12:10
sure, why not?

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com
Go to Top of Page

Mjolnir
Starting Member

12 Posts

Posted - 2008-03-09 : 09:34:55
done!!

thank you!
Go to Top of Page

dataguru1971
Master Smack Fu Yak Hacker

1464 Posts

Posted - 2008-03-09 : 09:35:28
quote:
Originally posted by Mjolnir

Hi,

I want to delete automatically all the fridays 11 Pm the complete content of my table.

How do I to do this?

Sorry my stupid question but I dont have idea how to do this.

Mjolnir.




Asking how to do this is not a stupid question.

However, coming back on Saturday morning asking how to un-delete your data might be a different story.

Presume you have some kind of storage for the data as of Friday at 11 PM, since your intent is to remove all the table contents?





Poor planning on your part does not constitute an emergency on my part.

Go to Top of Page

Mjolnir
Starting Member

12 Posts

Posted - 2008-03-09 : 09:41:19
ups, How can I to set a scheduled backup? with a job too?
Go to Top of Page

Mjolnir
Starting Member

12 Posts

Posted - 2008-03-09 : 09:50:02
dataguru1971,

Is a little system used for student to get access to labs, this is weekly service.

The next week the students use the system to get access to this again.

They insert this registers, name, identification document, date (the application save the register date) and student course year, 5th, 4th 3th year.

The fridays in the mourning the secretary generate a list with the students and the currents fields in the table be delete this are not needed.

The problem is if the IT guy dont delete the table rows, this mix the old registers with the new registers.

With the reply of spirit1 I solved the problem, but my wife tell me that the secretary is very irresponsible and generate this the fridays or the mondays, when the day to do this are the fridays.

(For this now I need perform a automatic backup before a clean the table.)

The fridays the application is closed. The students need awaiting for the list published by the secretary.

Hope can understand me.

kind regards,

Mjolnir.
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2008-03-09 : 10:12:24
you can execute a Backup database in a job too yes.

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com
Go to Top of Page

Mjolnir
Starting Member

12 Posts

Posted - 2008-03-09 : 10:37:47
I use this code to do the automatic backup in the job:

'C:\AdventureWorks.Bak'
USE AdventureWorks
GO
BACKUP DATABASE AdventureWorks
TO DISK = 'C:\MSSQL\BACKUP\AdventureWorks.Bak'
WITH FORMAT,
NAME = 'Full Backup of AdventureWorks'
GO
-- Optionally, create a logical backup device,
-- AdventureWorks_Backup, for this backup file.
USE master
EXEC sp_addumpdevice 'disk', 'AdventureWorks_Backup',
'C:\MSSQL\BACKUP\AdventureWorks.Bak'


Thanks,

Mjolnir.
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2008-03-09 : 10:58:45
maybe you should add a date to the end of the name, just to be sure.

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com
Go to Top of Page
   

- Advertisement -