Dawn y
Your suggestion of query timeout is excellent.
In the original post I do not see any mention of stored procedure on server side !
So it seems to be a case of execution of dynamic SQL getting out of control !
Khoa Tran
There is a global variable @@spid to get spid for each connection. You need to get it before you start your big query execution. Use it with caution for killing the spid later if needed.
Please do not use sp_who or select from master..sysprocesses because these can aggravate the situation if CPU usage is already high.
HTH
Avinash