Move SQL Server data in limited (1000 row) chunks
问题 I'm writing a process that archives rows from a SQL Server table based on a datetime column. I want to move all the rows with a date before X, but the problem is that there are millions of rows for each date, so doing a BEGIN TRANSACTION...INSERT...DELETE...COMMIT for each date takes too long, and locks up the database for other users. Is there a way that I can do it in smaller chunks? Maybe using ROWCOUNT or something like that? I'd originally considered something like this: SET ROWCOUNT