public bool BackupAA()
{
int temp = 0;
int tempdel = 0;
string sql = "INSERT INTO [WMSBAK].[dbo].[AACopy] SELECT * FROM [TestDB].[dbo].[AA] WHERE AddDate <= DATEADD( d ,-45,GETDATE())";
try
{
temp = dbhelper.ExcuteNonequery(sql);
}
catch (Exception)
{
}
if (temp > 0)
{
string delsql = "DELETE [TestDB].[dbo].[AA] WHERE AddDate < DATEADD( d ,-45,GETDATE())";
try
{
tempdel = dbhelper.ExcuteNonequery(delsql);
}
catch (Exception)
{
throw;
}
if (tempdel > 0)
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
跨库备份指定日期前数据表,然后从原表删除
时间: 2024-11-05 06:24:19