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;
}
}
跨库备份指定日期前数据表,然后从原表删除,布布扣,bubuko.com
原文地址:http://www.cnblogs.com/porray/p/3770244.html