仅备份新的或编辑的记录

发布于 2024-08-12 23:28:09 字数 124 浏览 2 评论 0 原文

我已经构建了一个 SQL Server Express 数据库,该数据库将存储在外部硬盘上。我需要能够在我的系统以及其他系统上的数据库上添加/更新数据,然后仅备份或传输已添加或编辑到外部硬盘驱动器的数据。实现这一目标的最佳方法是什么?

I have built a SQL Server Express database that is going to be housed on an external hd. I need to be able to add/update data on the database that is on my system, as well as other systems and then only backup or transfer data that has been added or edited to the external hard drive. What is the best way to accomplish this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

无风消散 2024-08-19 23:28:09

您可能会为此使用复制,但由于您使用的是 SQL Server Express,因此这不是一个选项。

您需要某种机制来确定备份之间发生了什么变化。因此,每个表都需要一个时间戳或上次更新日期时间列,每次插入或更新记录时都会更新该列。从触发器而不是从您的应用程序更新此列可能更容易。

一旦您知道插入或更新了哪些记录,那么只需从上次执行操作时搜索这些记录即可。

另一种方法是添加一个已更新的位列,但这似乎不太灵活。

You would probably use replication for this but as you're using SQL Server express this isn't an option.

You'll need some sort of mechanism to determine what has changed between backups. So each table will need a timestamp or last updated date time column that's updated every time a record is inserted or updated. It's probably easier to update this column from a trigger rather than from your application.

Once you know which records are inserted or updated then it's just a matter of searching for these from the last time the action was performed.

An alternative is to add a bit column which is updated but this seems less flexible.

海的爱人是光 2024-08-19 23:28:09

Sherry,请解释一下应用程序以及您设计的基本原理。数据库没有任何机制可以做到这一点。您必须自己跟踪更改,然后执行您需要执行的操作。 SQL Server 2008 内置了更改跟踪功能,但我认为这对您使用 Express 没有帮助。

另外,请查看同步框架。将其添加到您的平台中是一个主要的有效负载,但如果保持数据同步是您应用程序的主要目标之一,那么它可能会给您带来回报。

Sherry, please explain the application and what the rationale is for your design. The database does not have any mechanism to do this. You'll have to track changes yourself, and then do whatever you need to do. SQL Server 2008 has a change tracking feature built in, but I don't think that will help you with Express.

Also, take a look at the Sync Framework. Adding this into your platform is a major payload, but if keeping data in sync is one of the main objectives of your app, it may pay off for you.

反话 2024-08-19 23:28:09

在应用程序中

如果您在应用程序中执行此操作,则每次更新或插入行时 - 修改名为 dirty 的位/布尔列并将其设置为 true。当您选择要导出的行时,请仅选择 dirty 设置为 true 的列。导出后,将所有脏列设置为 false。

在应用程序外部

DTS 向导

如果您在应用程序外部执行此操作,则在命令行中运行此操作:

Run  "C:\Program Files\Microsoft SQL Server\90\DTS\Binn\DTSWizard.exe" 

文章解释如何获取 DTS 向导(默认情况下不包含)。

它包含在 SQL Server 中
Express 版工具包 – 并且唯一
那。如果你安装了另一个
SSE版本,它工作得很好
之后安装这个包
无需卸载其他。得到
它在这里:
http://go.microsoft.com/fwlink/?LinkId=65111< /p>

DTS 向导包含在
选项“商业智能
开发工作室”所以一定要
选择要安装的

如果您安装了其他版本
SSE 的,安装程序可能会报告
没有什么可安装的。
通过选中复选框来覆盖它
显示版本号(在
安装程序向导)

安装完成后,DTS
向导可在
c:\\Microsoft SQL
Server\90\DTS\Binn\dtswizard.exe 你
可能想走捷径,甚至
将其包含在 SQL 的工具菜单中
工作室。

bcp 实用程序

bcp 实用程序在 Microsoft SQL Server 实例和数据之间批量复制数据 >用户指定格式的文件。 bcp 实用程序可用于导入大量 >将新行添加到 SQL Server 表中或将表中的数据导出到数据文件中。除外>当与 queryout 选项一起使用时,该实用程序不需要 Transact-SQL 知识。
要将数据导入表中,您必须使用为该表创建的格式文件或 >了解表的结构以及对其有效的数据类型
列。

In an application

If you are doing this from an application, every time a row is updated or inserted - modify a bit/bool column called dirty and set to true. When you select the rows to be exported, then select only columns that have dirty set to true. After exporting, set all dirty columns to false.

Outside an application

DTS Wizard

If you are doing this outside of an application, then run this at the Command-Line:

Run  "C:\Program Files\Microsoft SQL Server\90\DTS\Binn\DTSWizard.exe" 

This article explains how to get the DTS Wizard (it is not included as default).

It is included in the SQL Server
Express Edition Toolkit – and only
that. It you have installed another
version of SSE, it works fine to
install this package afterwards
without uninstalling the others. Get
it here:
http://go.microsoft.com/fwlink/?LinkId=65111

The DTS Wizard is included in the
option “Business Intelligence
Development Studio” so be sure to
select that for install

If you have installed another version
of SSE, the installer might report
that there is nothing to install.
Override this by checking the checkbox
that displays the version number (in
the installer wizard)

After install has finished, the DTS
Wizard is available at
c:\\Microsoft SQL
Server\90\DTS\Binn\dtswizard.exe you
might want to make a shortcut, or even
include it on the tools menu of SQL
Studio.

bcp Utility

The bcp utility bulk copies data between an instance of Microsoft SQL Server and a data > file in a user-specified format. The bcp utility can be used to import large numbers of > new rows into SQL Server tables or to export data out of tables into data files. Except > when used with the queryout option, the utility requires no knowledge of Transact-SQL.
To import data into a table, you must either use a format file created for that table or > understand the structure of the table and the types of data that are valid for its
columns.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文