티스토리 뷰
job실행 SP msdb.dbo.sp_start_job @job_name = 'jobName'
MSSQL 서버 에이전트 모니터링 쿼리.
----------------------------------------------------------------------------------------------------------------------------------------------
--SQL SERVER AGENT 모니터링
SELECT
A.name
, A.description
, B.last_run_date
, B.last_outcome_message
, B.last_run_date
, C.next_run_date
FROM msdb.dbo.sysjobs AS A WITH (NOLOCK)
INNER JOIN msdb.dbo.SYSJOBSERVERS AS B WITH (NOLOCK) ON A.job_id = B.job_id
LEFT OUTER JOIN msdb.dbo.sysjobschedules AS C WITH (NOLOCK) ON A.job_id = C.job_id
--WHERE SYS_SRVS.last_run_outcome = 0 --실패작업 , 1-- 성공작업
----------------------------------------------------------------------------------------------------------------------------------------------
--SQL SERVER AGENT 모니터링
SELECT
A.job_id
, A.name
, A.enabled
, description
, A.date_created
, A.date_modified
, D.step_id
, D.step_name
, D.subsystem
, D.command
FROM msdb.dbo.sysjobs A WITH (NOLOCK)
INNER JOIN msdb.dbo.sysjobschedules B WITH (NOLOCK) ON A.job_id = B.job_id
INNER JOIN msdb.dbo.sysschedules C WITH (NOLOCK) ON B.schedule_id = C.schedule_id
INNER JOIN msdb.dbo.sysjobsteps D WITH (NOLOCK) ON A.job_id = D.job_id
ORDER BY A.job_id, D.step_id
----------------------------------------------------------------------------------------------------------------------------------------------
--SQL SERVER AGENT 모니터링
SELECT
A.Name
, Result = Case When B.Last_Run_OutCome = 1 Then 'Success'
Else 'Fail'
End
, B.Last_Run_Date
, Convert(Varchar(10),(B.Last_Run_Time / 10000))+'시'+CONVERT(VARCHAR(10),(B.Last_Run_Time % 10000) / 100)+'분' AS Last_Run_Time
, C.Next_Run_Date
, Convert(Varchar(10),(C.Next_Run_Time / 10000))+'시'+CONVERT(VARCHAR(10),(C.Next_Run_Time % 10000) / 100)+'분' AS Next_Run_Time
, B.Last_Run_Duration
FROM msdb.dbo.sysjobs AS A WITH(READUNCOMMITTED)
LEFT JOIN msdb.dbo.sysjobservers AS B WITH(READUNCOMMITTED) ON A.Job_Id = B.Job_Id
LEFT JOIN msdb.dbo.sysjobschedules AS C WITH(READUNCOMMITTED) ON A.Job_Id = C.Job_Id
--WHERE
-- SJ.Enabled = 1
-- AND SJSCH.Next_Run_Date IS NOT NULL
ORDER BY B.Last_Run_Date, B.Last_Run_Time
----------------------------------------------------------------------------------------------------------------------------------------------
참고 출처
http://www.sqler.com/bColumn/271911
http://bbolltang.tistory.com/10
'프로그래밍 > MSSQL' 카테고리의 다른 글
테이블이 사용하고있는 함수나 / 뷰를 조회하는 쿼리 (0) | 2012.06.01 |
---|---|
MSSQL 날짜 더하기 dateadd (0) | 2012.05.31 |
MSSQL 날짜 Convert 형식 (날짜 형식 변환) (0) | 2012.05.29 |
CASE문 세로쿼리를 가로로 변경 (0) | 2012.05.07 |
MSSQL schema 변경 (스키마 변경) (0) | 2012.04.25 |
- Total
- Today
- Yesterday
- rowspan
- Mobile
- css3
- json
- MSSQL
- jquery chart
- Ajax
- 프로시저
- jQuery
- ASP.NET
- radius
- JavaScript
- WCF
- grid
- CSS
- JS
- WebApi
- Excel
- SVG
- 제이쿼리
- 저장프로시저
- html5
- IE
- Style
- jQuery Mobile
- 자바스크립트
- workbook
- Chart
- 셀렉터
- drag&drop
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |