标签:card 数据库地址 code strong protoc dsr ide col service
--以下脚本在本地执行 --创建链接服务器 --替换11.222.32.126 改成另外一台的数据库地址 --替换 sa 改成另外一台的数据库地址的用户名 --替换 SZ 改成另外一台的数据库地址的密码 exec sp_addlinkedserver ‘ITSV1‘ , ‘‘ , ‘SQLOLEDB‘ , ‘11.222.32.126‘ ; exec sp_addlinkedsrvlogin ‘ITSV1‘ , ‘false‘ , null , ‘sa‘ , ‘SZ‘ ; GO select * into #table_temp from ITSV1.YGT.dbo.OPP_BUSI_DATA where 1=2; insert into #table_temp select * from ITSV1.YGT.dbo.OPP_BUSI_DATA WHERE PROC_STATUS in (‘11‘,‘01‘) AND KIDM_SNO != ‘‘ AND USER_TYPE !=‘‘ AND OPER_TIME < GetDate(); DELETE FROM BUSI_DATA_INFO where EXT_B_SNO in (select B_SNO from #table_temp); UPDATE #table_temp SET CUST_CODE=‘0‘ WHERE CUST_CODE = ‘‘; MERGE INTO BUSI_DATA_INFO T1 USING ( SELECT * FROM #table_temp ) S1 ON (T1.EXT_B_SNO = S1.KIDM_SNO) WHEN NOT MATCHED THEN INSERT ( B_SNO, BUSI_CODE, CUST_NAME, ID_TYPE, ID_CARD, USER_TYPE, ORG_CODE, SYS_CUST_NO, SYS_CODE, CREATE_DATE, CHANNEL, ACCEPT_PARAM, EXT_B_SNO ) VALUES ( S1.B_SNO, S1.BUSI_CODE, S1.CUST_NAME, S1.ID_TYPE, S1.ID_CODE, S1.USER_TYPE, S1.OP_ORG, S1.CUST_CODE, ‘99‘, S1.OPER_TIME, S1.YZT_CHANNEL, S1.ACCEPT_PARAM, S1.B_SNO ) ; if object_id(‘tempdb..#table_temp‘) is not null Begin drop table #table_temp End GO exec sp_dropserver ‘ITSV1‘ , ‘droplogins‘ GO
--以下脚本在本地执行 -- 替换 sa 用户名 --一ygtt数据库 -- 替换 test 密码 --一ygtt数据库 -- 替换 11.222.32.126 IP 1521 端口号 --ygtt的数据库 -- 替换 服务器名ygt--一柜通的 create public database link dblinkname connect to sa identified by test using ‘(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST =11.222.32.126)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME =ygtt)))‘; create global temporary table table_temp as select * from OPP_BUSI_DATA@dblinkname where 1=2; insert into table_temp select * from OPP_BUSI_DATA@dblinkname WHERE PROC_STATUS in (‘11‘,‘01‘) AND KIDM_SNO IS NOT NULL AND USER_TYPE IS NOT NULL AND OPER_TIME < SYSDATE ; DELETE FROM BUSI_DATA_INFO where EXT_B_SNO in (select B_SNO from table_temp); UPDATE table_temp SET CUST_CODE=‘0‘ WHERE CUST_CODE is null; MERGE INTO BUSI_DATA_INFO T1 USING ( SELECT * FROM table_temp ) S1 ON (T1.EXT_B_SNO = S1.KIDM_SNO ) WHEN NOT MATCHED THEN INSERT ( B_SNO, BUSI_CODE, CUST_NAME, ID_TYPE, ID_CARD, USER_TYPE, ORG_CODE, SYS_CUST_NO, SYS_CODE, CREATE_DATE, CHANNEL, ACCEPT_PARAM, EXT_B_SNO ) VALUES ( S1.B_SNO, S1.BUSI_CODE, S1.CUST_NAME, S1.ID_TYPE, S1.ID_CODE, S1.USER_TYPE, S1.OP_ORG, S1.CUST_CODE, ‘99‘, S1.OPER_TIME, S1.YZT_CHANNEL, S1.ACCEPT_PARAM, S1.B_SNO ) ; drop table table_temp; drop public database link dblinkname;
标签:card 数据库地址 code strong protoc dsr ide col service
原文地址:https://www.cnblogs.com/ouycx/p/11758833.html