What's blocking “Select top 1 * from TableName with (nolock)” from returning a result?

前端 未结 4 1884
余生分开走
余生分开走 2021-02-20 14:37

I\'m currently running the following statement

select * into adhoc..san_savedi from dps_san..savedi_record

It\'s taking a painfully long time a

4条回答
  •  天命终不由人
    2021-02-20 14:56

    Find the session_id that is performing the select into:

    SELECT r.session_id, r.blocking_session_id, r.wait_type, r.wait_time
      FROM sys.dm_exec_requests AS r
      CROSS APPLY sys.dm_exec_sql_text(r.plan_handle) AS t
      WHERE t.[text] LIKE '%select%into%adhoc..san_savedi%';
    

    This should let you know if another session is blocking the select into or if it has a wait type that is causing a problem.

    You can repeat the process in another window for the session that is trying to do the select. I suspect Martin is right and that my earlier comment about schema lock is relevant.

提交回复
热议问题