ESP - Delete Old Message
/*
This will delete all old XML messages
and events older then 5 days
SFL 2008-11-29 Created
Status
6 = history
5 =
4 = processing
3 = success
2 = pending
1 = failed
0 = created
*/
delete from infbigtext where foreignId <> 1 and lastchanged < dateadd(d,-5,getdate()) and foreigntype like 'Message%'
delete from infapplicationevent where createddate < dateadd(d,-5,getdate())
--Delete Messages too
declare @id int
declare look cursor for
Select id from mscmessage where processeddate < dateadd(d,-5,getdate()) and status in (3,6)
open look
fetch next from look into @id
while @@fetch_status=0
begin
update mscmessage set previousMessageID=null where previousMessageID=@id
delete from mscmessage where id=@id
fetch next from look into @id
end
close look
deallocate look
delete from infexception where mainttime < dateadd(dd,-5,getdate())