每隔一段时间就从服务端下载数据使用sql语句实现

来源:互联网 发布:中国乒乓球 知乎 编辑:程序博客网 时间:2024/06/08 08:47
项目需求,就简单介绍一下我是怎么实现的。具体操作大家可以随时联系我<img alt="大笑" src="http://static.blog.csdn.net/xheditor/xheditor_emot/default/laugh.gif" />
主要分为两步:
一、用sql语句实现从远程数据库下载数据
二、利用windows自带的任务管理器执行你的bat脚本,其中的bat脚本是用来执行你的sql语句的
--将 服务端 192.168.121.203 主机上的 数据 每隔一段时间就下载一次。就算你的时间 在 50到65之间也是可以有办法获得的!--因为我使用的是条件判断语句--这是客户端代码declare @flag intset @flag =((select datepart(minute,getdate()))-19)if @flag>0beginselect * from openrowset('SQLOLEDB', '192.168.121.203'; 'sa'; '123', test_02.dbo.stu_infor)where insert_minute <= (select datepart(minute,getdate()))andinsert_minute > ((select datepart(minute,getdate()))-6)andinsert_hour = (select datepart(hour,getdate()))end;else beginselect * from openrowset('SQLOLEDB', '192.168.121.203'; 'sa'; '123', test_02.dbo.stu_infor)where insert_minute<=(select datepart(minute,getdate())+60)andinsert_minute>=((select datepart(minute,getdate())+60)-19)unionselect * from openrowset('SQLOLEDB', '192.168.121.203'; 'sa'; '123', test_02.dbo.stu_infor)where insert_hour = (select datepart(hour,getdate()))end;二、bat文件如下:
osql -S . -d 数据库名称-U 用户名 -P 密码 -i 上面的数据库文件名.sql具体解释
三、至于windows人物管理器可以在开始菜单中找到

1 0