views:

231

answers:

2

how does sql-server handle infinite loops? Does it detect it or kill the server.

EG:

WHILE (@number = 3)
BEGIN
    print @number
END
+5  A: 

It depends on the client command timeout.

By default, a .net app will abort in 30 seconds and SSMS will wait forever (timeout = zero)

By itself, the SQL Server engine has no concept of "OK, I've had enough"

gbn
Nice answer. +1
Randolph Potter
+1  A: 

try it :) no it does NOT detect them. it's simply treated as a long running transaction.

also any kind of loop is sign of truely bad sql coding practice

Mladen Prajdic