sql server 查询某个表被哪些存储过程调用 select distinct object_name(id) from syscomments where id in (select id from sysobjects where type =’P’) and text like’%TableName%’…
SQL Server 查询锁表 select request_session_id spid,OBJECT_NAME(resource_associated_entity_id) as tableName ,* from sys.dm_tran_locks where resource_type='OBJECT' and OBJECT_NAME(resource_associated_entity_id) is not null SQL Server 解锁表 declare @spid int…
问题描述:只是单纯的执行了"select count(*) from 某表":数据表中只有一两条数据,能查询其他表,唯独这个表不能进行任何操作: 经百度搜索实验,发现应该是某个进程阻塞了,使用了一下代码进行的查询(这个比较详细): declare @spid int,@bl int ,blocked ) a ) b where a.blocked=spid) union )) + ' 进程号, 其执行的SQL 语法如下' else )))) +' 阻塞, 其当前进程执行的SQL 语法如…
1.查询某个表被哪些存储过程(以下简称 SP)使用到 : select distinct object_name(id) from syscomments where id in (select object_id from sys.objects where type ='P') and text like'%TableName%' 2.查找那些过程对该表做了更新操作: select distinct object_name(id) from syscomments where id in (…
一.查看表名和对应的数据行数select a.name as '表名',b.rows as '表数据行数'from sysobjects a inner join sysindexes bon a.id = b.idwhere a.type = 'u'and b.indid in (0,1)--and a.name not like 't%'order by b.rows desc 二.查看表名和表占用空间信息--判断临时表是否存在,存在则删除重建if exists(select 1 fr…
create table #Data(name varchar(100),row varchar(100),reserved varchar(100),data varchar(100),index_size varchar(100),unused varchar(100)) declare @name varchar(100) declare cur cursor for select name from sysobjects where xtype='u' order by name ope…