将更改从一个数据库更新到同一服务器中的另一个数据库

发布于 2024-08-31 20:28:01 字数 465 浏览 1 评论 0原文

我有一份名为“DBCopy”的客户端数据库副本,其中已包含修改后的数据。客户端数据库的副本 (DBCopy) 连接到中央数据库 (DBCentral) 所在的 SQL Server。然后我想更新什么 DBCopy 到 DBCentral 中已存在的更改。 DBCopy 和 DBCentral 具有相同的架构。我如何使用 C#.NET 以编程方式完成此操作,也许只需单击按钮即可。你能给我一个示例代码来说明如何做到这一点吗?我使用的是 SQL Server 2005 标准版和 VS 2008 SP1。

在实际场景中,大约有 7 个客户端数据库,全部与中央数据库具有相同的架构。我将每个客户端数据库的副本附加到中央数据库所在的中央服务器,并尝试使用 C# .NET 以编程方式将每个客户端数据库副本中存在的更改一一更新到中央数据库。客户端和中央服务器是位于不同位置的物理上独立的机器。它们并不相互关联。

我只需要更新和插入新数据。我不担心删除数据。

感谢和问候 帕万

I have a copy of client database say 'DBCopy' which already contains modified data. The copy of the client database (DBCopy) is attached to the SQL Server where the Central Database (DBCentral) exists. Then I want to update whatever
changes already present in DBCopy to DBCentral. Both DBCopy and DBCentral have same schema. How can i do it programatically using C#.NET maybe with a button click. Can you give me an example code as how to do it?. I am using SQL Server 2005 Standard Edition and VS 2008 SP1.

In the actual scenario there are about 7 client database all with same schema as the central database. I am bringing copy of each client database and attach it to Central Server where the central database resides and try to update changes present in each copy of the client database to central database one by one programatically using C# .NET . The clients and the central server are physically seperate machines present in different places. They are not interconnected.

I need to only update and insert new data. I am not bothered about deletion of data.

Thanks and regards
Pavan

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

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

发布评论

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

评论(4

給妳壹絲溫柔 2024-09-07 20:28:01

请查看同步框架。否则,创建一些 SSIS 包并运行它们。

Go check out Sync Framework. Otherwise, go create some SSIS packages and run them.

囚我心虐我身 2024-09-07 20:28:01

您所描述的内容听起来非常像数据库镜像

What you are describing sounds an awful lot like Database Mirroring.

冷情 2024-09-07 20:28:01

如果这是一次性或不频繁的同步,那么我会使用第三方工具,例如 Red-Gate 的 SQL Data Compare。如果这意味着持续同步,那么我建议复制或 同步框架

If this is a one-time or infrequent sync, then I'd use a third-party tool such as Red-Gate's SQL Data Compare. If this is meant as an ongoing sync, then I'd recommend replication or the Synchronization Framework.

柠北森屋 2024-09-07 20:28:01

我想这就是你想要的:-----

    USE DB1
UPDATE DB1.dbo.MyTable
SET
  Field1 = d2.Field1,
  Field2 = d2.Field2,
  Field3 = d2.Field3
FROM DB2.dbo.MyTable d2
WHERE d2.MyKey = MyTable.MyKey

i think this is wht u want:-----

    USE DB1
UPDATE DB1.dbo.MyTable
SET
  Field1 = d2.Field1,
  Field2 = d2.Field2,
  Field3 = d2.Field3
FROM DB2.dbo.MyTable d2
WHERE d2.MyKey = MyTable.MyKey
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文