Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Performdeletion.sql not working on CCR

Status
Not open for further replies.

robertrendle

Technical User
May 17, 2011
20
0
0
GB
Hi Chaps,

I have a problem with CCR 5.0.

The customers database is full, so I'm running the performdeletion.sql file, with the following :-

year @ 2012
month @ 1
day @ 1

and when I execute, I do not get any records deleted at all.

When I go in to the database using the management tool, I can see records that were created from dates before then (i.e in 2011)

Has anyone else had this type of problem before?

I get no errors when executing the performdeletion file.
 
Note that this is the script that's running :-

USE [AvayaSBCCRT]
GO

DECLARE @YEAR int;
DECLARE @MONTH int;
DECLARE @DAY int;

-- Specify the date in terms of year, month and day, of the oldest data you wish
-- to retain in the IPOCCR database. For example, the default values of 2009, 1 and 1
-- will cause any calls ending before 1st January 2009 to be deleted.
SET @YEAR = 2012
SET @MONTH = 1
SET @DAY = 1

DECLARE @oldestDate datetime
SELECT @oldestDate = min(DestroyDate) from tblCallList
IF @oldestDate IS NOT NULL
BEGIN
DECLARE @deleteToDate datetime
SET @deleteToDate = DATEADD(mm,(@YEAR-1900)* 12 + @MONTH - 1,0) + (@DAY-1)
PRINT 'All calls ending before '+CONVERT(nvarchar,@deleteToDate)+ ' will be deleted from the IPOCCR database'

DECLARE @callsToDelete int
SET @callsToDelete = (SELECT COUNT(CallListID) FROM tblCallList AS cl WHERE cl.DestroyDate < @deleteToDate)
PRINT 'The total number of calls deleted from the IPOCCR database will be '+CONVERT(nvarchar,@callsToDelete)

DELETE tblAgentActivity FROM tblAgentActivity AS aa
INNER JOIN tblCallList AS cl ON aa.CallListID = cl.CallListID
WHERE cl.DestroyDate < @deleteToDate
DELETE tblVoicemailSelection FROM tblVoicemailSelection AS vs
INNER JOIN tblCallList AS cl ON vs.CallListID = cl.CallListID
WHERE cl.DestroyDate < @deleteToDate

DELETE tblCallEnd FROM tblCallEnd AS ce
INNER JOIN tblCallList AS cl ON ce.CallListID = cl.CallListID
WHERE cl.DestroyDate < @deleteToDate
DELETE FROM tblCallList WHERE DestroyDate < @deleteToDate

DELETE FROM tblAlarmDetails WHERE ClearDate < @deleteToDate
DELETE tblAlarm FROM tblAlarm AS a
INNER JOIN tblAlarmDetails AS ads ON a.AlarmID = ads.AlarmID
WHERE ads.ClearDate < @deleteToDate

DELETE FROM tblAgentHGBridge WHERE DestroyDate < @deleteToDate

DELETE tblTrunkSupervisorBridge FROM tblTrunkSupervisorBridge AS tsb
INNER JOIN tblTrunkGroup AS tg ON tsb.TrunkGroupID = tg.TrunkGroupID
WHERE tg.DestroyDate < @deleteToDate
DELETE tblHGViewBridge FROM tblHGViewBridge AS hvb
INNER JOIN tblHuntGroup AS hg ON hvb.HGID = hg.HGID
WHERE hg.DestroyDate < @deleteToDate
DELETE tblHGSupervisorBridge FROM tblHGSupervisorBridge AS hsb
INNER JOIN tblHuntGroup AS hg ON hsb.HGID = hg.HGID
WHERE hg.DestroyDate < @deleteToDate

DELETE FROM tblLastStatReset WHERE ResetDate < @deleteToDate

DELETE FROM tblTrunkGroup WHERE DestroyDate < @deleteToDate
DELETE FROM tblVoicemailGroup WHERE DestroyDate < @deleteToDate
DELETE FROM tblHuntGroup WHERE DestroyDate < @deleteToDate
DELETE FROM tblSwitch WHERE DestroyDate < @deleteToDate

DELETE FROM tblDatabaseMonitorAlarms
END
ELSE
BEGIN
PRINT 'No data was found in the IPOCCR database to delete. Please proceed with installation.'
END
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top