I need to archive data from a rather large dataset to reclaim disk space. I want to creaste script with a data parameter, archive the data older than the date parameter to a seperate database, delete the data from the source then backup the arvhived database to tape. Below is my script. I would like to minimize the load placed on the server during execution - is this the best way to do this. Will these transactions be logged?? Is there a way to tell SQL to not log this process? below is my code:
Declare @PurgeDate as datetime
Set @PurgeDate = '01-01-2007'
--Archive Agent
Insert into dbo.Agent
Select Top 10 *
from hds.dbo.agent
where HDS_Sampledate < @PurgeDate
--Archive Agent_Month
Insert into dbo.Agent_Month
Select Top 10 *
from hds.dbo.agent_month
where HDS_Sampledate < @PurgeDate
--Archive DistributionFlat
Insert into dbo.DistributionFlat
Select Top 10 *
from hds.dbo.DistributionFlat
where HDS_Sampledate < @PurgeDate
--Archive HDSTableInfo
Insert into dbo.HDSTableInfo
Select Top 10 *
from hds.dbo.HDSTableInfo
where HDS_Sampledate < @PurgeDate
--Archive Policy
Insert into dbo.Policy
Select Top 10 *
from hds.dbo.Policy
where HDS_Sampledate < @PurgeDate
--Archive Policy_Month
Insert into dbo.Policy_Month
Select Top 10 *
from hds.dbo.Policy_Month
where HDS_Sampledate < @PurgeDate
Declare @PurgeDate as datetime
Set @PurgeDate = '01-01-2007'
--Archive Agent
Insert into dbo.Agent
Select Top 10 *
from hds.dbo.agent
where HDS_Sampledate < @PurgeDate
--Archive Agent_Month
Insert into dbo.Agent_Month
Select Top 10 *
from hds.dbo.agent_month
where HDS_Sampledate < @PurgeDate
--Archive DistributionFlat
Insert into dbo.DistributionFlat
Select Top 10 *
from hds.dbo.DistributionFlat
where HDS_Sampledate < @PurgeDate
--Archive HDSTableInfo
Insert into dbo.HDSTableInfo
Select Top 10 *
from hds.dbo.HDSTableInfo
where HDS_Sampledate < @PurgeDate
--Archive Policy
Insert into dbo.Policy
Select Top 10 *
from hds.dbo.Policy
where HDS_Sampledate < @PurgeDate
--Archive Policy_Month
Insert into dbo.Policy_Month
Select Top 10 *
from hds.dbo.Policy_Month
where HDS_Sampledate < @PurgeDate