• hi,

    for making the delete more performant you should use a loop, something like that:

    delete top ( 100000 ) from myTable

    while @@rowcount > 0

    begin

    delete top ( 100000 ) from myTable

    end

    For leaving some rows in the table there might be serveral ways. One could be querying count(*) of the table each time and breaking the loop but I think this would slow down the whole process a lot.

    Is there any ascending ID you can query? Then you could extend the query something like this:

    declare @rowcount bigint = 1;

    declare @MaxId bigint;

    select @MaxId = max(x.id) from ( select top 1000 Id from myTable ) as x

    while @rowcount > 0

    begin

    delete top ( 100000 ) from myTable where Id > @MaxId

    set @rowcount = @@rowcount;

    end