I found this code into our repository and I need to modify the statement. However, I am bit hesitant because I am wondering, why does it have two delete statements? I've tried to debug it, remove the first delete, it didnt work. I understand that it will run the delete per 100 rows. Is there an option that I can have the same behavior but only have one DELETE statement? TIA!
USE [DBQ]
SET ROWCOUNT 100
DELETE FROM dbo.setting WITH(ROWLOCK) WHERE CreateDate < DATEADD(day, -90, GETDATE())
WHILE @@rowcount > 0
BEGIN
SET ROWCOUNT 100
DELETE FROM dbo.setting WITH(ROWLOCK) WHERE CreateDate < DATEADD(day, -90, GETDATE())
END