定期从 SQLServer 2008 中的链接数据库获取数据
我们正在使用 SQL Server 2008 在 PHP 上开发一个系统。该系统必须与存储在另一个 SQL Server 实例中的发票一起使用,我已使用 sp_addlinkedserver 链接到我的数据库。
问题是我认为我需要在本地加载它(因为性能)。 Si 我正在考虑制作一个自己的“发票”表,每天两次以某种方式将数据从链接表带到本地存储的表。
我如何对 SQL 进行编程,使其每隔 X 时间执行一次此操作? 我应该使用什么方法来编程导入?
首先,我想制作自己的脚本来执行此操作,但我更愿意让 SQL Server 来处理此操作,但这取决于您的意见:)
谢谢您! Guillermo
注意:复制对我来说听起来太过分了。我不需要实时同步。我不需要更新数据库,只需读取即可。
We are developing a system on PHP with SQL Server 2008. Is a system that must work with the invoices stored in another SQL Server instance, that I have linked to my Database using sp_addlinkedserver.
The problem is that I think I need to have it loaded locally (because of performance). Si I'm thinking to make a my own "invoices" table, and two times per day somehow bring the data from the linked table to the locally stored one.
How can I program SQL to do this every X amount of time?
What approach I should use to program the importing?
It first I though to make my own script to do this, but I would preffer to have SQL Server to handle this, but that depends on your opinion :)
Thnak you!
Guillermo
NOTE: Replication sounds overkill for me.. I dont need to have real-time synconization. Neither I need to update the database, just read.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一种选择是使用复制来复制数据。但是,这可能需要比您计划的更多的管理。复制非常适合管理一致且及时的数据副本。
另一种选择是设置一个 SQL Server 作业,该作业将运行 SQL 脚本以使用链接服务器中的选择插入到目标表中。
您还可以使用 SQL Server 集成服务 (SSIS)。您将创建一个 SSIS 包,在其中构建将数据从源表传输到目标表的数据流。对于这种方法,您不需要链接服务器,因为您的数据源是在 SSIS 包中定义的。并且,您可以使用 SQL Server 作业来安排包运行时间。
One option is to use replication to copy the data. However, it may take more administration than you're planning. Replication is great for managing a consistent and timely copy of the data.
Another option is to setup a SQL Server job that will run a SQL script to insert into your target table using a select from your linked server.
You could also use SQL Server Integration Services (SSIS). You would create a SSIS package where you would build a data flow that transfers your data from the source table to the target table. You wouldn't need a linked server for this approach, because your data sources are defined within the SSIS package. And, you can use a SQL Server job to schedule the package run times.