Wswsqldelete - will delete data older than a certain date

--

**************************************************************

--SQL Script to delete old data from the websweeper database.

--

--Written By Craig Mills Clearswift Support

--

--2/10/02

--

--Instructions for use.

--Before using this script please change the @Before variable defined in the

--variables section, this needs to be the a valid date, any data before this

--date will be deleted.  

 

--Variables

 

DECLARE @Before nvarchar(30)

SELECT @Before = '2002-10-02 00:00:01.000'

 

--Main body of script

--woaTransactionDetail INNER JOIN GoaClassification where woaTransactionDetail.Id = goaClassification.Mapid

 

delete from goaclassifications WHERE MapID IN (select MapID from goaClassifications INNER JOIN woaTransactionDetail ON woaTransactionDetail.Id = goaClassifications.Mapid

where woaTransactionDetail.RequestTime < @Before)

delete from woatransactiondetail

where RequestTime < @Before delete from goaAuditHistory

where AtTime < @Before

delete from goaCustomEvents

where AtTime < @Before delete from goaEngineDetail

where StartTime < @Before

delete from woaauthenticationFailures

where AtTime < @Before

 

--Reorganises and removes unused space within SQL DBCC SHRINKDATABASE --(WSW)

--End of deletion script

--**************************************************************

 

Back

 
Site News
   
 
To Top