跨库备份指定日期前数据表,然后从原表删除
时间:2014-06-07 09:46:26
收藏:0
阅读:150
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;
}
}
评论(0)