I'm executing a SQL procedure on SQL Server for each line on my table. When I execute in SQL it runs every line. When I execute the same code in Python it executes only for around 10 lines and it closes (not pointing out any error). What could be the problem? My code: BEGIN SET NOCOUNT ON SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED DECLARE @pedido_id INT = 0 DECLARE c CURSOR FOR SELECT a.pedido_id FROM TABLE_SQL a order by a.pedido_id desc OPEN c FETCH FROM c INTO @pedido_id WHILE @@FETCH_STATUS = 0 BEGIN exec PROCEDURE_SQL @pedido_id FETCH NEXT FROM c INTO @pedido_id END CLOSE c DEALLOCATE c END I tried to execute code on SQL and it worked, but didn't work completely in Python (only for the first lines). I tried to change SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED for Read Committed, and other different levels but the result is the same. Continue reading...