Forum Moderators: open
Right now when I do a "delete from table where date < dateadd(month,-4,getdate())" the query cost is in the thousands.
Thanks,
DECLARE @orderid int
DECLARE mycursor CURSOR FOR
SELECT orderid
FROM orders
ORDER BY orderid
OPEN mycursor
-- Get the first row.
FETCH NEXT FROM mycursor
INTO @orderid
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT 'Deleting OrderID: ' + convert(varchar(15),@orderid)
-- INSERT YOUR DELETE STATEMENT HERE
-- Get the next row.
FETCH NEXT FROM mycursor
INTO @orderid
END
CLOSE mycursor
DEALLOCATE mycursor