SQL Server error: The lock request time-out period has been exceeded. (Microsoft SQL Server, Error: 1222) solution

Source: Internet
Author: User
Tags session id

--When many connect to your database, this error "has exceeded the lock request timeout period"
--just put the next-to-face stored procedure in your master database and execute it.

1  UsePratice2 SETAnsi_nulls on3 SETQuoted_identifier on4 Go5 6 Create PROC [dbo].[sp_killallprocessindb] @DbName VARCHAR( -)7  as8 IF db_id(@DbName)= NULL9 BEGINTen PRINT 'DataBase dose not Exist' One END A ELSE - BEGIN - DECLARE @killspId VARCHAR( -) the DECLARETmpcursorCURSOR -  for - SELECT 'Kill' + CONVERT(VARCHAR, spid) asspId -  fromMaster.. sysprocesses + WHERE db_name(dbid)= @DbName -  andspid<> @ @spid --terminates a process that is not the current process (not equal to the current process) +  anddbid<> 0 --database ID is not 0 A OPENTmpcursor at FETCH NEXT  fromTmpcursor -  -  into @killspId --SELECT INTO @killspId -  while @ @FETCH_STATUS = 0 - BEGIN - EXEC(@killspId) in FETCH NEXT  fromTmpcursor -  into @killspId to  + END -  the CLOSETmpcursor * deallocateTmpcursor $ ENDPanax Notoginseng  - execSp_killallprocessindb'the database to access'

(Reproduced above from: http://www.cnblogs.com/lyhabc/articles/3235601.html)

To view the locked process ID

SELECT ' ID of the blocking process ' ' wait Time (milliseconds) ' ' (session ID) '  from Sys.dm_os_waiting_tasks

SQL Server error: The lock request time-out period has been exceeded. (Microsoft SQL Server, Error: 1222) solution

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.