SQL INSERT INTO ... Select. Deadlock resolution

Source: Internet
Author: User
Keywords Network programming Database synthesis
Tags cpu kill network network programming process programming select text

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.