I am working in a database where I load data in a raw table by a data loader. But today the data loader got stuck for unknown reasons. Then I stopped the data loader from windows task manager. But then I again tried to load data in the raw table but found its locked and I can’t do any operation on it. I tried restarting SQL Server service but it was not resolved. And I have no permission to kill processes on this server.
Below is the message showed by SQL Server.
An exception occurred while executing a Transact-SQL statement or
batch. (Microsoft.SqlServer.ConnectionInfo)Program Location:
at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(String
sqlCommand, ExecutionTypes executionType)
at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(StringCollection
sqlCommands, ExecutionTypes executionType)
at Microsoft.SqlServer.Management.Smo.ExecutionManager.ExecuteNonQuery(StringCollection
queries)
at Microsoft.SqlServer.Management.Smo.SqlSmoObject.ExecuteNonQuery(StringCollection
queries, Boolean includeDbContext)
at Microsoft.SqlServer.Management.Smo.NamedSmoObject.RenameImplWorker(String
newName)
at Microsoft.SqlServer.Management.Smo.NamedSmoObject.RenameImpl(String
newName)===================================
Lock request time out period exceeded. Either the parameter @objname
is ambiguous or the claimed @objtype (OBJECT) is wrong. (.Net
SqlClient Data Provider)
Server Name: 162.44.25.59
Error Number: 1222
Severity: 16 State: 56
Procedure: sp_rename Line Number: 282
My SQL Server version is 2008 R2.
halfer
19.8k17 gold badges99 silver badges185 bronze badges
asked Nov 24, 2011 at 14:35
3
In the SQL Server Management Studio,
to find out details of the active transaction, execute following command
DBCC opentran()
You will get the detail of the active transaction, then from the SPID of the active transaction, get the detail about the SPID using following commands
exec sp_who2 <SPID>
exec sp_lock <SPID>
For example, if SPID is 69 then execute the command as
exec sp_who2 69
exec sp_lock 69
Now , you can kill that process using the following command
KILL 69
starball
16.3k6 gold badges31 silver badges154 bronze badges
answered Feb 28, 2014 at 10:06
5
It’s been a while, but last time I had something similar:
ROLLBACK TRAN
or trying to
COMMIT
what had allready been done free’d everything up so I was able to clear things out and start again.
answered Nov 25, 2011 at 15:18
shawtyshawty
5,7292 gold badges35 silver badges71 bronze badges
2
To prevent this, make sure every BEGIN TRANSACTION has COMMIT
The following will say successful but will leave uncommitted transactions:
BEGIN TRANSACTION
BEGIN TRANSACTION
<SQL_CODE?
COMMIT
Closing query windows with uncommitted transactions will prompt you to commit your transactions. This will generally resolve the Error 1222 message.
codingbiz
26.1k8 gold badges57 silver badges95 bronze badges
answered Jan 27, 2016 at 22:01
Paul TotzkePaul Totzke
1,44017 silver badges33 bronze badges
I had these SQL behavior settings enabled on options query execution: ANSI SET IMPLICIT_TRANSACTIONS checked. On execution of your query e.g create, alter table or stored procedure, you have to COMMIT it.
Just type COMMIT and execute it F5
marc_s
729k175 gold badges1327 silver badges1455 bronze badges
answered Jun 27, 2019 at 13:38
In my case, I was trying to disable a trigger on a table when I received error 1222 «Lock request time out period exceeded.»
I followed suggestions in this answer:
- Open two query windows in SSMS.
- In the first, type/paste the command that is timing out (due to a lock). In the lower right hand corner of SSMS, you should see the username and (in parentheses) the SPID of the connection you’re using. Note the SPID of this query window connection. Don’t execute this query just yet.
- In the second query window, type/paste
SELECT * FROM sysprocesses WHERE spid = <
SPID you noted in step 2>
- Execute the first query that is timing out, and while it is executing (but before it times out) switch over to the second query window and execute it (the
SELECT * from sysprocesses...
one) - You should get some results in the results pane. Look at the ‘blocked’ field in the results. In my case, it contained the SPID of the process that was locking the table.
- Research the locking process further by executing
SELECT * FROM sysprocesses WHERE spid = <
SPID from the ‘blocked’ field in step 5>
. - If the locking process can be safely terminated, kill it with
kill <locking SPID>
answered May 25, 2021 at 21:30
BaodadBaodad
2,3852 gold badges36 silver badges39 bronze badges
- Remove From My Forums
-
Question
-
We’re running a SQL-Server 2012 and for a while now my accessing records from bigger tables became tricky.
There is a Tomcat-8 running which sometimes can’t access these tables at all or only after a long delay. As this happened first I went to the Server-Room and opened the Database with the Management Studio to see if there were any issues. Strangely I could
open the Database but expanding the directories for «Tables» or «Views» failed after 10 Seconds with the Error 1222.I turned the Tomcat-8 off to find out whether some unclosed connections are open. Same result, no changes even after one hour.
Another 3rd-Party program which we are using seems to connect via other mechanisms to the SQL-Server (Is there a way to list current connections and their types in the Management-Studio, please let me know so I’m able to provide this information too) But
I’m under the impression this program does a lot of caching, it’s much faster than the Management-Studio itself.The question is now how can I find out why these time-outs happen? I’m not an expert in SQL-Servers so please let me know how I can provide missing information.
Thank you
Answers
-
I don’t think there is a way to configure that lock timeout of 10 seconds. By default, there is no lock timeout in SQL Server, but it is possible that Object Explorer in SSMS sets one up, so it will remain unresponsive forever if there is blocking.
The information given is quite vague, and I am not at all acquainted with Tomcat-8. I have a procedure on my web site which is good for analysing blocking situations and the ongoing activity in the server. You may find it useful:
http://www.sommarskog.se/sqlutil/beta_lockinfo.html
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
-
Marked as answer by
Saturday, October 24, 2015 4:01 PM
-
Marked as answer by
Stuck with an error 1222 microsoft sql server? Bobcares is at your service!
The error 1222 is a common error when you are working in Microsoft SQL Server Management Studio. It often pops up when you are attempting to view tables, procedures, or tables in object explorer. Find out how our Support engineers helped out a customer with their SQL server 1222 error recently.
What is MS SQL server error 1222?
The error is a result of a longer query wait time than lock timeout settings. The lock timeout indicates the time spent waiting for a backend resource to be available.
Fortunately, the Support Engineers at Bobcares have a quick fix for this.
Tips to resolve the pesky error 1222 Microsoft SQL server
Now that you have got an idea about why error 1222 pops up. Let’s dive into resolving the issue once and for all.
- Our engineers use sp_who2 to check the currently established sessions in the database as well as any sessions with high CPU usage, blocking, high I/O usage, or sessions with multiple entries for identical SPID. This may be the cause behind lock time-outs.
- You can change the lock time-out period by running the following command:
SET LOCK_TIMEOUT timeout_period
The timeout_period indicates the number of milliseconds allowed to pass before a locking error is returned by Microsoft SQL Server. Its default value is -1, which specifies no time-out period. Changing the lock time-out period will prevent error 1222 from occurring frequently.
[Looking for assistance with Server Management? We are just a click away]
Conclusion
This easy fix to resolve Microsoft SQL server management studio error 1222 tip comes from our top experts at Bobcares.
If you have any queries about your SQL server or server management, do not hesitate to contact us. We have been helping customers successfully resolve issues related to server management for a long time.
PREVENT YOUR SERVER FROM CRASHING!
Never again lose customers to poor server speed! Let us help you.
Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.
GET STARTED
Question: I’m on SSMS and trying to access the SQL Server instance but I’m getting this error:
Lock request timeout period exceedd Error 1222
Normally I can access the server and there haven’t been any security changes. What could be causing this problem?
Answer: The basis of the Error 1222 is that a transactions is holding a lock on the target resource for a longer period than the query could wait for.
There are different situations that can trigger the error message.
Example 1 : Someone running a transaction with a BEGIN TRAN but no ROLLBACK or COMMIT. The transaction could be locking the system tables.
The quickest way to sort out the issue is to identify the active transaction details.
In the SQL Server Management Studio, to find out details of the active transaction, execute following command
DBCC opentran()
for more details read:
SQL Server — SQL open transactions and how to find
SQL Server — How to find Open Transactions
If you think you’re creating the issue through a transaction executed through the SSMS, you could shut the SSMS. Slightly drastic , but it will normally solve your problem
Author: Tom Collins (http://www.sqlserver-dba.com)
Share:
While working in Microsoft SQL Server Management Studio, you receive an error while viewing trees, tables, or procedures in object explorer. This error typically occurs when a query waits longer that the lock timeout settings. The lock timeout is in milliseconds that waits for a backend resource to be available (the default lock timeout is -1). In most cases, a query fails with the lock request time out period error after waiting for more than 10ms.
- Use sp_who2 to check for all session that are currently established in the database and check for any with blocking, high CPU usage, high I/O usage, or any with multiple entries for the same SPID. These will be causing your lock time out’s and you will need to troubleshoot accordingly.
- You can adjust the LOCK_TIMEOUT setting following this Microsoft SQL guide here.
* Please use the comment form below. Comments are moderated.*