/**********************************************************************************************
-- Title : [2k] Linked Server 연결 및 원격 사용자 지정, RPC 설정
-- Reference : dBRang.com
-- Key word : sp_dropserver, sp_addlinkedserver, sp_addlinkedsrvlogin, sp_serveroption
linked server linkedserver 연결된서버 연결된 서버
**********************************************************************************************/
-- 기본 서버 정보 확인
EXEC sp_helpserver
-- 기존 링크드 서버 삭제
EXEC sp_dropserver 'AN2SRV', droplogins
-- 링크드 서버 연결
EXEC sp_addlinkedserver
@server = 'AN2SRV' -- 연결 서버명 지정
, @srvproduct = ''
, @provider = 'SQLOLEDB'
, @datasrc = 's_an2' -- 연결될 서버명 지정
, @catalog = ''
-- 원격 로그인 등록
EXEC sp_addlinkedsrvlogin
@rmtsrvname = 'AN2SRV' -- 연결 서버명 지정
, @useself = false
, @locallogin = null
, @rmtuser = 'sa' -- 연결할 서버의 원격 계정 이름
, @rmtpassword = '0000' -- 연결될 서버의 원격 계정 암호
-- RPC in/out 설정
-- RPC 설정 없을 시 원격 프로시저 실행이 안된다.
exec sp_serveroption 'AN2SRV', 'rpc out', 'true'
exec sp_serveroption 'AN2SRV', 'rpc', 'true'
---------------------------------------------------------------------------------------
-- dbguide.com에서 본 내용
-- For Insert or Update on Remote Server...
-- You have to GRANT Insert or Update Authority on Remote TABLE ot Remote User...
-- I granted Insert and update authority on Remote Table using EM Tool.
---------------------------------------------------------------------------------------
-- DML을 위해.. sp_serveroprtion 을 주나보다..ㅡㅡ???(뭐 하자는지 테스트 안됨..ㅡㅡ;)
SP_SERVEROPTION A_SERVER, 'data access', TRUE - B_SERVER에서 실행
SP_SERVEROPTION B_SERVER, 'data access', TRUE - A_SERVER에서 실행