在多个数据库中插入/更新行 [英] Insert/Update row in multiple databases

查看:89
本文介绍了在多个数据库中插入/更新行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

该应用程序有一个SystemDB和多个客户数据库。客户数据库完全相同(所有表都相同)。系统数据库包含一个表,其中包含来自客户数据库的所有详细信息,如dbname,dbPassword,dbUsername等。如果我们在应该将数据存储在所有数据库中的表单中插入数据。

解决方案

1。如果数据库位于同一服务器中,则使用如下命令

  INSERT   INTO  DBName.dbo.Customer(Column1,Column2) VALUES ' < span class =code-string>',' '



2.如果数据库驻留在远程服务器上。

正如你告诉你在你的一个系统表中有DBName,Id密码所以使用这个值就可以了使用OPENQUERY和动态SQL。欲了解更多信息,请查看

http://msdn.microsoft.com/ en-us / library / ms188427.aspx [ ^ ]


The application has one SystemDB and multiple customer databases. The customer databases are exactly the same(all tables are equal). The system databases contains a table with all the details from the customer databases like dbname, dbPassword,dbUsername, etc.. . If we insert Data in forms that should stored the data in all the databases.

解决方案

1. If the database resides in same server then use command like below

INSERT INTO DBName.dbo.Customer(Column1,Column2) VALUES('','')


2.If database resides in remote server.
As you told that you have DBName,Id password in one of your system table so using this value you can use OPENQUERY with dynamic SQL. For more information have a look
http://msdn.microsoft.com/en-us/library/ms188427.aspx[^]


这篇关于在多个数据库中插入/更新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆