某些情况下,sqlserver的表会被锁住,比如某个会话窗口有数据一直没提交,窗口又没关闭,这时表就会被锁住 其他任何连接查询表数据时都不会返回 这时需要手工杀掉产生死锁的会话ID,才能恢复正常 查看被锁表: select request_session_id spid,OBJECT_NAME(resource_associated_entity_id) tableName from sys.dm_tran_locks where resource_type='OBJECT' s
select request_session_id spid,object_name(resource_associated_entity_id) tableName from sys.dm_tran_locks where resource_type='object' --spid 锁表进程 --tableName 被锁表名 --解锁: declare @spid int Set @spid =57--锁表进程 declare @sql varchar(1000) set @sql='kil
1,查看那个表死锁 select object_name(resource_associated_entity_id) as tableName, request_session_id as pid from sys.dm_tran_locks where resource_type = 'OBJECT' 2,结束死锁的进程
SQLServer查看死锁 if exists ( select * from sys.procedures where name like '%USP_ShowLocks%' ) drop procedure dbo.USP_ShowLocks go create procedure dbo.USP_ShowLocks as begin create table #t ( req_spid int ,obj_name sysname ) declare @s nvarchar(4000) ,@
sql语句,怎么查看一个表中的所有约束,比如,一个student表,有唯一,外键,主键,用sql语句怎么查看student表中的所有约束呢? select * from sysobjects where parent_obj in(select id from sysobjects where name='student')