일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
- 테이블 명세서
- ㅗ기
- mssql 로그축소
- 이루나전기
- 엑셀 두개 창
- 늑대와여우
- 엑셀 2007 여러 개
- 엑셀 참조창
- power builder
- 윈도우
- 늑여탭
- 이루나
- 엑셀 두개 창 열기
- 로그파일 축소
- MSSQL
- Excel
- 엑셀 창모드
- 파워빌더
- 원격데스크톱
- 데이터윈도우
- 로그축소
- RDP
- svn
- 카달로그뷰
- 엑셀 여러개 창 열기
- 엑셀 여러 창
- Windows
- Shrink log
- 파워빌더 팁
- 이클립스
- Today
- Total
why don't do your best
DB 락킹 모니터 하는 프로시져 sp_lock2 본문
CREATE PROC [dbo].[sp_lock2]
(
@dbname sysname = NULL,
@spid int = NULL
)
AS
/************************************************************************************
Copyright © 2001 Narayana Vyas Kondreddi. All rights reserved.
Purpose: To display detailed lock information
Written by: Narayana Vyas Kondreddi
Tested on: SQL Server 7.0 and SQL Server 2000
Date modified: August-13-2001 12:00 AM
Examples:
To see all the locks:
EXEC sp_lock2
To see all the locks in a particular database, say 'pubs':
EXEC sp_lock2 pubs
To see all the locks held by a particular spid, say 53:
EXEC sp_lock2 @spid = 53
To see all the locks held by a particular spid (23), in a particular database (pubs):
EXEC sp_lock2 pubs, 23
***********************************************************************************/
BEGIN
SET NOCOUNT ON
CREATE TABLE #lock
(
spid int,
dbid int,
ObjId int,
IndId int,
Type char(5),
Resource char(20),
Mode char(10),
Status char(10)
)
INSERT INTO #lock EXEC sp_lock
IF @dbname IS NULL
BEGIN
IF @spid IS NULL
BEGIN
SELECT a.spid AS SPID,
(SELECT DISTINCT program_name FROM master..sysprocesses WHERE spid = a.spid) AS [Program Name],
db_name(dbid) AS [Database Name], ISNULL(object_name(ObjId),'') AS [Object Name],IndId, Type, Resource, Mode, Status
FROM #lock a
END
ELSE
BEGIN
SELECT a.spid AS SPID,
(SELECT DISTINCT program_name FROM master..sysprocesses WHERE spid = a.spid) AS [Program Name],
db_name(dbid) AS [Database Name], ISNULL(object_name(ObjId),'') AS [Object Name],IndId, Type, Resource, Mode, Status
FROM #lock a
WHERE spid = @spid
END
END
ELSE
BEGIN
IF @spid IS NULL
BEGIN
SELECT a.spid AS SPID,
(SELECT DISTINCT program_name FROM master..sysprocesses WHERE spid = a.spid) AS [Program Name],
ISNULL(object_name(a.ObjId),'') AS [Object Name],a.IndId,
ISNULL((SELECT name FROM sysindexes WHERE id = a.objid and indid = a.indid ),'') AS [Index Name],
a.Type, a.Resource, a.Mode, a.Status
FROM #lock a
WHERE dbid = db_id(@dbname)
END
ELSE
BEGIN
SELECT a.spid AS SPID,
(SELECT DISTINCT program_name FROM master..sysprocesses WHERE spid = a.spid) AS [Program Name],
ISNULL(object_name(a.ObjId),'') AS [Object Name],a.IndId,
ISNULL((SELECT name FROM sysindexes WHERE id = a.objid and indid = a.indid ),'') AS [Index Name],
a.Type, a.Resource, a.Mode, a.Status
FROM #lock a
WHERE dbid = db_id(@dbname) AND spid = @spid
END
END
DROP TABLE #lock
END
'Database > MSSQL' 카테고리의 다른 글
mssql 홑따옴표 넣기 (0) | 2013.01.10 |
---|---|
mssql 테이블 데이터 스크립팅 법 (0) | 2013.01.05 |
db 블록킹 상태 프로시져 sp_block 프로시져 (0) | 2012.12.11 |
SSMS 테이블을 수정할수 없습니다. Timeout이 만료되었습니다. (0) | 2012.12.10 |
잠금시간설정 (0) | 2012.12.10 |