Advertisement
tei219

sp_lock

Nov 25th, 2011
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.53 KB | None | 0 0
  1. create table #sp_lock (
  2. spid    smallint,
  3. dbid    smallint,
  4. objid   int,
  5. indid   smallint,
  6. type    nchar(4),
  7. resource    nchar(32),
  8. mode    nvarchar(8),
  9. status  nvarchar(5)
  10. )
  11. insert into #sp_lock exec sp_lock
  12. alter table #sp_lock add objname nvarchar(200) null
  13. exec sp_MSforeachdb @command1 = '
  14. use ?
  15. update #sp_lock set objname = object_name(objid) where dbid = db_id(''?'')
  16. '
  17. go
  18. select db_name(dbid) as dbname, objid, objname, count(*) as count from #sp_lock group by dbid, objid, objname order by dbid, objname, objid
  19. drop table #sp_lock
  20. go
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement