0

I created some columns in our production database but now I need to drop one. However this seems impossible and I do not know why. I dropped the column in our development database just fine. I created a table in production and dropped that. But when I try to remove this one column I get the error. I used management studio (which fails quickly) and T-SQL (which takes longer but still fails).

ALTER TABLE VEN DROP COLUMN RI_VEN_Approved

lock request time out period exceeded

Any idea whats going on?

I checked for locks using a query found here: https://stackoverflow.com/questions/1511675/how-to-check-if-a-table-is-locked-in-sql-server

Using this query specifically:

SELECT resource_type, resource_associated_entity_id,
request_status, request_mode,request_session_id,
resource_description, o.object_id, o.name, o.type_desc 
FROM sys.dm_tran_locks l, sys.objects o
WHERE l.resource_associated_entity_id = o.object_id
and resource_database_id = DB_ID()

The table did not appear in the results.

I ran sp_who2 and did not see anything in the BlkBy column.

  • Check for blocking when you are attempting to run the drop column command, chances are that there are queries actively running against the object, blocking your drop process. – Nic Jul 14 '17 at 15:38
  • @Nic if sp_who2 will identify blocking then ther is nothing blocking anything. – DropDude Jul 14 '17 at 16:58
2

Drop the table using T-SQL as then the query will not timeout but instead get blocked. Note down the spid of this query window (it should be visible in the bottom of SSMS, right next to username). Once this goes into "executing" stage, open another query window and do this,

use master
go
select * from sysprocesses where spid = <spid of the query which is dropping the table\column>

Look at the blocked column and note down the spid number. Next query to see who the owner of the spid is (this will tell you who owns the conflicting lock on this table).

select * from sysprocesses where spid = <spid # from above blocked column>

Once you identify this, you can use dbcc inputbuffer(spid) to find out what query/command it is doing that has taken a lock on this table. If you deem that query inconsequential, then you can kill it using kill <spidnumber>. After this your query for the drop table/Column should complete.

Updated: Try to drop column ALTER TABLE table_name DROP COLUMN column_name;

Check this link: https://social.msdn.microsoft.com/Forums/sqlserver/en-US/77fc7e09-ed14-481f-89d5-d5e143dab7bd/trying-to-delete-a-table-in-sql-server-management-studio-and-getting-a-strange-error?forum=sqldatabaseengine

  • There is no query. Just a column to be removed. Also this is a table with data so it can not be dropped. – DropDude Jul 14 '17 at 16:51
  • 1
    While creating column did you add any KEYS (primary or Foreign)? Did you Try with command: ALTER TABLE table_name DROP COLUMN column_name; – CR241 Jul 14 '17 at 16:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.