Microsoft sql server ошибка 1222

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's user avatar

halfer

19.8k17 gold badges98 silver badges185 bronze badges

asked Nov 24, 2011 at 14:35

user960340's user avatar

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's user avatar

starball

14.9k6 gold badges26 silver badges131 bronze badges

answered Feb 28, 2014 at 10:06

AbdulRahman Ansari's user avatar

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

shawty's user avatar

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's user avatar

codingbiz

26.1k8 gold badges57 silver badges95 bronze badges

answered Jan 27, 2016 at 22:01

Paul Totzke's user avatar

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's user avatar

marc_s

728k174 gold badges1327 silver badges1455 bronze badges

answered Jun 27, 2019 at 13:38

Jerry Iriri's user avatar

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:

  1. Open two query windows in SSMS.
  2. 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.
  3. In the second query window, type/paste SELECT * FROM sysprocesses WHERE spid = <SPID you noted in step 2>
  4. 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)
  5. 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.
  6. Research the locking process further by executing SELECT * FROM sysprocesses WHERE spid = <SPID from the ‘blocked’ field in step 5>.
  7. If the locking process can be safely terminated, kill it with kill <locking SPID>

answered May 25, 2021 at 21:30

Baodad's user avatar

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

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.

  1. 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.
  2. 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

Permalink

Cannot retrieve contributors at this time

title description author ms.author ms.date ms.service ms.subservice ms.topic helpviewer_keywords

MSSQLSERVER_1222

MSSQLSERVER_1222

MashaMSFT

mathoma

04/04/2017

sql

supportability

reference

1222 (Database Engine error)

MSSQLSERVER_1222

[!INCLUDE SQL Server Azure SQL Database Azure SQL Managed Instance]

Details

Attribute Value
Product Name SQL Server
Event ID 1222
Event Source MSSQLSERVER
Component SQLEngine
Symbolic Name LK_TIMEOUT
Message Text Lock request time out period exceeded.

Explanation

Another transaction held a lock on a required resource longer than this query could wait for it.

User Action

Perform the following tasks to alleviate the problem:

  1. Locate the transaction that is holding the lock on the required resource, if possible. Use sys.dm_os_waiting_tasks and sys.dm_tran_locks dynamic management views.

  2. If the transaction is still holding the lock, terminate that transaction if appropriate.

  3. Execute the query again.

If this error occurs frequently change the lock time-out period or modify the offending transactions so that they hold the lock for less time.

Posted On 2018-12-29

При попытке посмотреть свойства базы данных SQL возникает ошибка SQL Server Error 1222. Какая-то транзакция блокирует базу.

Я решил так

В SQL Server Management Studio, чтобы узнать подробности активной транзакции, выполните следующую команду

DBCC opentran()

Вы получите подробную информацию о активной транзакции, затем из SPID активной транзакции, получите подробную информацию о SPID, используя следующие команды

exec sp_who2 <SPID>
exec sp_lock <SPID>

Например, если SPID равен 69, тогда выполните команду как

exec sp_who2 69
exec sp_lock 69

Теперь вы можете убить этот процесс, используя следующую команду

KILL 69

Понравилась статья? Поделить с друзьями:
  • Microsoft sql server ошибка 102
  • Microsoft sql server ошибка 10054
  • Microsoft solitaire collection ежедневные задания ошибка загрузки
  • Microsoft sharepoint ошибка
  • Microsoft setup bootstrapper office 2016 ошибка