My application uses SQL Server 2014. It has a table called Report
. I have the following stored procedure to delete records.
create procedure delteReportsByIds
@ids varchar(8000)
as
begin
exec ('delete from Report where id in ( '+ @ids +' )')
end
The data passed to ids
is something like
1,4,6
which deletes 3 records with ID being 1, 4, 6. Here is the problem. Now the table is very large and ID of a record has reached 7 digits, something like
1380025
So the stored procedure can only delete a max 1000 records (with 7 digit IDs) at one time. It seems that I am unable to increase the 8000 limit. How can I delete 2000 records with the above procedure at one time?