SQL INSERT INTO ... Select. Deadlock resolution
Method One
INSERT into a SELECT * out B with (Xlock) where form_no= @form_no method two, stored procedure
sp_who--sql2000 and above
DBCC INPUTBUFFER (SPID)--for viewing specific statements
Kill spid-kills the process.
--or
SELECT * from sys.sysprocesses--sql2005 and above
A. Queries based on average CPU time in the top five
This scenario provides information about CPU time, IO read-write, and the number of execution times for the top five queries by average CPU time. Copy Code
Select Top 5
Total_worker_time/execution_count as [AVG CPU time],
(Select substring (TEXT,STATEMENT_START_OFFSET/2, Case statement_end_offset =-1 then len (nvarchar (max), Text) * 2 else statement_end_offset End-statement_start_offset)/2) from Sys.dm_exec_sql_text (sql_handle)) as Query_ Text
From Sys.dm_exec_query_stats
ORDER BY [AVG CPU TIME] desc