SQL Server Agent Job에서 sysploicy_purge_history  작업실패

 

·       Version : SQL Server

 

SQL Server 2008 이후로 SQL Server Agent Job에서는 syspolicy_purge_history라는 job 등록되어 있다해당 Job MSDB 쌓여 있는 히스토리를 정리하는 작업을 진행한다 가끔 해당 Job 실행시 아래와 같은 오류가 발생할  있는데오류가 무엇인지 확인해보고 해결하는 방법에 대해서 살펴 본다.

 

Job 실패하였을때해당 로그를 살펴보면 아래와 같은 오류로그가 발생하였다.

Date                    7/29/2019 1:23:41 PM

Log                       Job History (syspolicy_purge_history)

 

Step ID                3

Server                

Job Name                         syspolicy_purge_history

Step Name                       Erase Phantom System Health Records.

Duration                           00:00:00

Sql Severity        0

Sql Message ID  0

Operator Emailed          

Operator Net sent         

Operator Paged

Retries Attempted          0

 

Message

Executed as user: NT Service\SQLSERVERAGENT. The job script encountered the following errors. These errors did not stop the script:  A job step received an error at line 1 in a PowerShell script. The corresponding line is 'import-module SQLPS'. Correct the script and reschedule the job. The error information returned by PowerShell is: 'The specified module 'SQLPS' was not loaded because no valid module file was found in any module directory.  '  A job step received an error at line 1 in a PowerShell script. The corresponding line is 'SQLSERVER:'. Correct the script and reschedule the job. The error information returned by PowerShell is: 'The term 'SQLSERVER:' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.  '.  Process Exit Code -1.  The step failed.

 

해당 Job  실행하는 명령을 직접 Powershell콘솔에서 실행하여도 아래와 같은 오류가 발생한다.

 

해당 오류는 명령이 참조하는 모듈의 PATH 설정이 누락되어 발생한 경우로시스템 변수에서 해당 변수값을 지정하면 해결이 가능하다모듈의 PATH 경로는 SQL 버전마다 조금씩 다르며 아래 경로를 참고할  있도록 한다.

C:\Program Files (x86)\Microsoft SQL Server\140\Tools\PowerShell\Modules

 

모듈이 위치한 경로를 확인하였으면 [My Computer] – [right click] – [Properties]에서 [Advance] 탭을 선택하여 [Environmeont Variables]  클릭한다 PSModulePath 이름으로 모듈이 위차한 PATH 등록(또는 수정)한다.

 

경로가 올바르게 수정되었으면, SQLPS 시작하여 정상적으로 PATH 설정이 완료되었는지 확인이 가능하다또는 SQL Agent에서 해당 Job 실행하여 정상적으로 실행이 되는지 확인할  있다.

 

 

[참고자료]

https://blog.sqlauthority.com/2016/03/08/sql-server-syspolicy_purge_history-job-failing-step-erase-phantom-system-health-records/

 

2019-08-07 / Sungwook Kang / http://sungwookkang.com

 

SQL Server, Agent job, sysploicy_purge_history , Agent 히스토리 삭제, PSModulePath, Erase Phantom System Health Records



출처: https://sqlmvp.tistory.com/1330?category=618825 [Database Lab]
No. Subject Author Date Views
Notice SQL강좌: 챗GPT와 함께 배우는 SQL Server 무료 강좌 목차와 소개 (2023년 9월 업데이트) 코난(김대우) 2023.08.18 38722
Notice Python 무료 강좌 - 기초, 중급, 머신러닝(2023년 6월 업데이트) 코난(김대우) 2021.01.01 20805
» SQL Server Agent Job에서 sysploicy_purge_history 작업실패 jevida(강성욱) 2019.09.04 1456
2173 where절 case관련... BGT051 2019.09.03 1481
2172 SQL Server에서 테이블 이름을 변경하지 않고 테이터만 교체하기 jevida(강성욱) 2019.05.03 2236
2171 SQL Server master 데이터베이스 정리 jevida(강성욱) 2019.04.23 4887
2170 SQL Server 프로토콜과 SQLCMD를 사용한 연결 jevida(강성욱) 2019.04.23 1754
2169 SQL Server Edition 다운그레이드 후 확인사항 [1] jevida(강성욱) 2019.04.23 1658
2168 AlwaysOn 구성환경에서 Server Role 체크 후 Job Agent 실행 중지하기 jevida(강성욱) 2019.04.23 1041
2167 SSRS에서 E-mail 세팅시 SSL 사용 유무 수정하기 jevida(강성욱) 2019.03.26 943
2166 SQL Linux Instance Name 변경 jevida(강성욱) 2019.03.26 828
2165 SQL Linux 업그레이드 jevida(강성욱) 2019.03.26 1083
2164 Azure SQL Managed Instance 에서 SQL Agent의 Job history 기록 보관하기 jevida(강성욱) 2019.03.26 945
2163 Azure VM에서 SQL Server에 대한 저장소 구성 지침 jevida(강성욱) 2019.03.26 947
2162 Azure SQL에 도입된 새로운 집계 함수 APPROX_COUNT_DISTINCT jevida(강성욱) 2019.03.26 725
2161 Azure SQL의 데이터베이스 소유권 체인 jevida(강성욱) 2019.03.26 832
2160 Azure SQL의 내부 디스크 할당 방법 및 저장 가능 용량 확인 jevida(강성욱) 2019.03.26 857
2159 Azure SQL에서 이메일 보내기 jevida(강성욱) 2019.03.26 741
2158 Azure SQL에서 읽기 전용 복제본에 대한 접속 및 링크 서버 생성 jevida(강성욱) 2019.03.26 841
2157 Azure SQL에서 네트워크를 구성하는 방법 jevida(강성욱) 2019.03.26 587
2156 인덱스 재구성과 통계 업데이트시 발생하는 SQL Server Block jevida(강성욱) 2019.03.26 852
2155 SQL Server Scala UDF Inline 기능을 사용한 쿼리 성능 향상 jevida(강성욱) 2019.03.26 729





XE Login