时间:2021-07-01 10:21:17 帮助过:14人阅读
--执行存储过程
exec batch_import ‘001‘
--单独处理"zsb_rvinfo"表
delete from zsb_rvinfo
insert into zsb_rvinfo select * from ITSV.DBName.dbo.zsb_rvinfo
--以后不再使用时删除链接服务器
exec sp_dropserver ‘ITSV‘, ‘droplogins‘
--跨服务器复制单表数据
insert into zsb_rvinfo select TOP (20000) * from openrowset(‘sqloledb‘,‘192.168.1.10‘;‘sa‘;‘sa@1234‘,‘select * from ..zsb_rvinfo‘)
其他相关
--数据存入临时表 select * into ##TempTable from ITSV.DBName.dbo.zsb_customer --多条id相同的数据,取日期最新的 select * from zsb_customer t where not exists (select 1 from zsb_customer where id=t.id and 日期>t.日期) -- 定义游标. DECLARE @ctm_id VARCHAR(10); DECLARE customer_fast CURSOR FAST_FORWARD FOR SELECT ctm_id FROM res_zsb_customer; -- 打开游标. OPEN customer_fast; WHILE 1=1 BEGIN -- 填充数据. FETCH NEXT FROM customer_fast INTO @ctm_id; if(@ctm_id != ‘‘) -- 假如未检索到数据,退出循环. IF @@fetch_status!= 0 BREAK; --PRINT @value; END;
sql server 命令
标签:ops link 处理 name etc exists customer into delete