Note that there are some explanatory texts on larger screens.

plurals
  1. POSQL hangs when executed as SP but is fine as SQL
    primarykey
    data
    text
    <p>Greetings, I have been analyzing a problem with a delete stored procedure. The procedure simply performs a cascading delete of a certain entity.</p> <p>When I break the SP out into SQL in the query editor it runs in approx. 7 seconds, however, when the SP is executed via EXEC SP it takes over 1 minute to execute.</p> <p>I have tried the following with no luck:</p> <ul> <li>Dropped the SP and then recreated it using WITH RECOMPILE </li> <li><p>Added SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED</p></li> <li><p>The SQL runs in the editor with many concurrent connections without issue.</p></li> <li>The EXEC Procedure hangs with or without concurrent connections</li> </ul> <p>The procedure is similar to:</p> <pre><code> ALTER PROCEDURE [dbo].[DELETE_Something] ( @SomethingID INT, @Result INT OUT, @ResultMessage NVARCHAR(1000) OUT )--WITH RECOMPILE--!!!DEBUGGING AS --SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED--!!!DEBUGGING SET @Result=1 BEGIN TRANSACTION BEGIN TRY DELETE FROM XXXXX --APPROX. 34 Records DELETE FROM XXXX --APPROX. 227 Records DELETE FROM XXX --APPROX. 58 Records DELETE FROM XX --APPROX. 24 Records DELETE FROM X --APPROX. 14 Records DELETE FROM A -- 1 Record DELETE FROM B -- 1 Record DELETE FROM C -- 1 Record DELETE FROM D --APROX. 3400 Records !!!HANGS FOR OVER ONE MINUTE TRACING THROUGH SP BUT NOT SQL GOTO COMMIT_TRANS END TRY BEGIN CATCH GOTO ROLLBACK_TRANS END CATCH COMMIT_TRANS: SET @Result=1 COMMIT TRANSACTION RETURN ROLLBACK_TRANS: SET @Result=0 SET @ResultMessage=CAST(ERROR_MESSAGE() AS NVARCHAR(1000)) ROLLBACK TRANSACTION RETURN </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload