Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

Backup

Use FTAE_Historian
Go
BACKUP DATABASE FTAE_Historian
TO DISK = 'C:\FTAE_Historian.BAK'
WITH FORMAT,
MEDIANAME = 'SQLServerBackups',
NAME = 'Full Backup of FTAE_Historian';
Use BatchHistoryEx
go
BACKUP DATABASE BatchHistoryEx
TO DISK = 'C:\BatchHistoryEx.BAK'
WITH FORMAT,
MEDIANAME = 'SQLServerBackups',
NAME = 'Full Backup of BatchHistoryEx';
Use Diagnostics
go
BACKUP DATABASE Diagnostics
TO DISK = 'C:\Diagnostics.BAK'
WITH FORMAT,
MEDIANAME = 'SQLServerBackups',
NAME = 'Full Backup of Diagnostics';
Use masterrecipes
go
BACKUP DATABASE masterrecipes
TO DISK = 'C:\masterrecipes.BAK'
WITH FORMAT,
MEDIANAME = 'SQLServerBackups',
NAME = 'Full Backup of masterrecipes';
Shrink
declare @StartTime AS DateTime = ‘2018-02-01 00:00:00.000’
Use FTAE_Historian
DELETE ConditionEvent
WHERE EventTimeStamp < @StartTime
DELETE SimpleEvent
WHERE EventTimeStamp < @StartTime
DELETE TrackingEvent
WHERE EventTimeStamp < @StartTime

Use BatchHistoryEx
DELETE BHBatch
WHERE endtimebatchlist < @StartTime
DELETE BHBatchHis
WHERE lclTime < @StartTime
DELETE BHBinding
WHERE eventtime < @StartTime
DELETE BHChangeHistory
WHERE Lcltime < @StartTime
DELETE BHComment
WHERE eventtime < @StartTime
DELETE BHControlSteps
WHERE eventtime < @StartTime
DELETE BHDeviationEvents
WHERE starttime < @StartTime
DELETE BHEquipment
WHERE Lcltime < @StartTime
DELETE BHFailure
WHERE eventtime < @StartTime
DELETE BHFailureClear
WHERE eventtime < @StartTime
DELETE BHMaterialEvent
WHERE eventtime < @StartTime
DELETE BHModeChange
WHERE eventtime < @StartTime
DELETE BHModeCommand
WHERE eventtime < @StartTime
DELETE BHOperation
WHERE endtime < @StartTime
DELETE BHParameter
WHERE eventtime < @StartTime
DELETE BHParameterChange
WHERE eventtime < @StartTime
DELETE BHPhase
WHERE endtime < @StartTime
DELETE BHPrompt
WHERE eventtime < @StartTime
DELETE BHPromptResponse
WHERE eventtime < @StartTime
DELETE BHStateChange
WHERE eventtime < @StartTime
DELETE BHStateCommand
WHERE eventtime < @StartTime
DELETE BHTempBatch
WHERE endtimebatchlist < @StartTime
DELETE BHUnit
WHERE endtime < @StartTime
DELETE BHUnitProcedure
WHERE endtime < @StartTime
Use Diagnostics
DELETE Diagnostic_Log
WHERE TimeStmp < @StartTime
DELETE FloatTable
WHERE DateAndTime < @StartTime
DELETE StringTable
WHERE DateAndTime < @StartTime
Leave it as is I worked for testing Query
ALTER DATABASE FTAE_Historian SET RECOVERY SIMPLE

GO

DBCC SHRINKFILE (FTAE_Historian, 5)

GO

ALTER DATABASE FTAE_Historian SET RECOVERY FULL

GO

declare @StartTime AS DateTime = ‘2018-02-01 00:00:00.000’


DELETE BHBatchHis
WHERE lclTime < @StartTime

You might also like