EXEC sys.sp_addlinkedserver '目标服务器的别名', '', 'SQLOLEDB', '目标服务器的地址';
EXEC sys.sp_addlinkedsrvlogin '目标服务器的别名', 'false', NULL, '账号', '密码';
--远程查询
SELECT * FROM [93SERVER].[hr_zzqy20181228].[dbo].code WHERE code_type = 'HIS_DEPARTMENT'
--将远程数据导入本地
INSERT INTO code (FACILITY_ID,CODE_TYPE,CODE_VALUE,CODE_DESC,ENTERED,ENTERED_BY,VERSION_NUM,PARENT_CODE_ID,OBSOLETE_YN,MISC_VALUE1) SELECT FACILITY_ID,CODE_TYPE,CODE_VALUE,CODE_DESC,ENTERED,ENTERED_BY,VERSION_NUM,PARENT_CODE_ID,OBSOLETE_YN,MISC_VALUE1 FROM [93SERVER].[hr_zzqy20181228].[dbo].code WHERE code_type = 'HIS_DEPARTMENT'
INSERT INTO PHYSICIAN (PHYS_NAME, HIN_PHYS_IDENT, PHYS_REGISTRATION_IDENT, ENTERED, ENTERED_BY, VERSION_NUM, FACILITY_ID, PHYS_CLASS, IP_ADDRESS, TIP_CLOSE_TIME, TELEPHONE, ABX_PRESCRIBE_RIGHT, JM_FLAG, DEPARTMENT_NAME, PHYSICIAN_JOB, PHYSICIAN_POST, CHESTCARD_NO, IDCARD_NO, PHYSICIAN_GENDER, PHYSICIAN_DOB, FLAG, HEARTBEAT_TIME, MAC_ADDRESS, LOGIN_NUM) SELECT PHYS_NAME, HIN_PHYS_IDENT, PHYS_REGISTRATION_IDENT, ENTERED, ENTERED_BY, VERSION_NUM, FACILITY_ID, PHYS_CLASS, IP_ADDRESS, TIP_CLOSE_TIME, TELEPHONE, ABX_PRESCRIBE_RIGHT, JM_FLAG, DEPARTMENT_NAME, PHYSICIAN_JOB, PHYSICIAN_POST, CHESTCARD_NO, IDCARD_NO, PHYSICIAN_GENDER, PHYSICIAN_DOB, FLAG, HEARTBEAT_TIME, MAC_ADDRESS, LOGIN_NUM FROM [93SERVER].[hr_zzqy20181228].[dbo].PHYSICIAN