Home > database >  SQL server table is locked, can't modify the table structure, also cannot be deleted
SQL server table is locked, can't modify the table structure, also cannot be deleted

Time:04-28

Is what reason can't not clear tables,
SQL server table is locked, unable to rename table, can't modify the table structure, cannot delete, modify times wrong
The time has come "timed out, before the operation is completed over time has passed or server is not responding"

Checked online solution may be to lock, found did table is locked, he performed after "kill process,"

Unlock times wrong
"The ongoing transaction rollback, estimate the rollback has been completed: 0%, estimated time remaining: 0 seconds"

Has been performed, when performing a drop table can't do,

List the amount of data is very small, there is no data congestion caused by the

Because it is very important to design the database, can't restart the server, so ask if there is any other way?

CodePudding user response:

 
Declare @ spid int
The Set @ spid=74 - process lock table
Declare @ SQL varchar (1000)
The set @ SQL='kill' + cast (@ spid as varchar)
The exec (@ SQL)

If this statement can't unlock, table or occupied, not restart the MSSQL, there is only one way, such as the obvious process blocked

CodePudding user response:

Open the SQL Server Management Studio, two new query connection,
Connect 1 performs the following SQL:
 
Select @ @ spid - & gt; Take note of this process SPID value

Drop table [table name]

Then, connect 2 perform the following SQL:
 
- check the source of blocking the connection 1 process SPID
The select blocked
The from sys. Sysprocesses
Where spid=spid value [link]

Kill [blocked value]
  • Related