ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • [MSSQL] Ad Hoc 옵션 유효화
    SQL Server 2021. 11. 6. 17:16


    내가 잊어버리지 않으려고 쓰는 블로그

    연결된 서버를 이용하여 테이블 복사를 할 경우
    쿼리에는 문제가 없는데 실행이 안되는 때가 있다.
    「메시지 15281, 수준 16, 상태 1, 줄 1
    SQL Server blocked access to STATEMENT 'OpenRowset/OpenDatasource' of component 'Ad Hoc Distributed Queries' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'Ad Hoc Distributed Queries' by using sp_configure. For more information about enabling 'Ad Hoc Distributed Queries', search for 'Ad Hoc Distributed Queries' in SQL Server Books Online.」

    하지만 에러 내용을 보면 친절하게 Ad Hoc Distributed Queries옵션을 유효화하라고 알려준다.
    그럼 유효화하는 방법을 살펴보자.
    ① configure옵션 범위를 전부 표시

    1
    EXEC sp_configure 'show advanced options''1';
    cs

    아래 메세지내용이 출력됨
    「Configuration option 'show advanced options' changed from 0 to 1. Run the RECONFIGURE statement to install.」
    ② 현재 Ad Hoc Distributed Queries옵션값을 확인 (config_value값이 0이면 무효화, 1이면 유효화)

    ③ Ad Hoc Distributed Queries옵션값을 유효화 (0→1)

    1
    2
    EXEC sp_configure 'Ad Hoc Distributed Queries''1';
    RECONFIGURE WITH OVERRIDE
    cs

    아래 메세지내용이 출력됨
    「Configuration option 'Ad Hoc Distributed Queries' changed from 0 to 1. Run the RECONFIGURE statement to install.」
    ④ Ad Hoc Distributed Queries옵션값 확인(config_value값)

    ⑤ configure옵션 범위를 원래대로 돌려놓기

    1
    EXEC sp_configure'show advanced options','0';
    cs

    아래 메세지내용이 출력됨
    「Configuration option 'show advanced options' changed from 1 to 0. Run the RECONFIGURE statement to install.」

    이제 연결된 서버를 이용한 테이블 복사가 가능해짐

Designed by Tistory.