-
AppRuntimeVar设置
- 存储过程
[dbo].[p_GetDataFromHIS]
CREATE PROC [dbo].[p_GetDataFromHIS]
-- 1.创建远程链接服务器
EXEC sp_addlinkedserver 'server_link','','SQLOLEDB','远程服务器ip(如172.16.2.190)'
EXEC sp_addlinkedsrvlogin 'server_link','false',null,'远程数据库用户名(如sa)','远程数据库密码(如123456)'
GO
-- 2.追加插入数据
INSERT INTO HL7.dbo.Table1
SELECT *
FROM server_link.[HemoSystem].dbo.Table1 AS t
WHERE t.startDate
BETWEEN '2016-01-01 00:00:00.000'
AND '2016-02-01 00:00:00.000'
GO
-- 3.在[AppRuntimeVar]重设开始时间
UPDATE [HemoSystem].[dbo].[AppRuntimeVar]
SET Value = '2016-02-01 00:00:00.000'
WHERE KeyWord = 'starttime'
GO
-- 4.不再使用时删除链接服务器
EXEC sp_dropserver 'server_link','droplogins'
GO