从.sql脚本将数据附加到现有SQL数据库 [英] Appending data to an existing SQL database from .sql script

查看:295
本文介绍了从.sql脚本将数据附加到现有SQL数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个需要使用用户提供的指纹,图片和其他数据进行用户注册的应用程序。这是为了拥有它的数据库,并将安装在许多计算机上。另一个应用程序,主要应用程序,完成其余的工作。现在,我想从注册应用程序中作为备份生成的.sql脚本中的任何计算机将数据从注册数据库传输到主应用程序数据库。所以我的问题是,我该怎么做,因为如果我尝试正常恢复,它会覆盖数据库中的现有数据。我需要一些帮助。

I''m writting an application that requires user registration using fingerprints, pictures and other data supplied by the user. This is to hav its database and would be installed on many computers. And another application, the main application that does the rest of the work. Now i want to transfer the data from the registration database to the main application database from any of the computers from a .sql script produced as backup from the registration apps. So my question is, how would i do this, because if i try normal restore, it overwrites the existing data in the database. Please i need some help.

推荐答案

Emejulu,



您的问题需要更多解释。他们有什么SQL服务器版本?注册数据库中的表是否与主数据库的布局相同?,您是否想要一个自动作业,每晚从一个数据库唤醒并将数据复制到另一个数据库?

你想使用一个SSIS包?你想使用shell脚本来复制数据吗?您可以使用bcp将数据提取到文本文件,然后使用bcp将数据导入主db。有很多方法可以将数据从一个数据库传输到另一个数据库。



cocis。
Emejulu,

Your question requires a lot more explanation. What SQL server version do they have? Are the tables from the registration database the same layout as the Main database?, do you want a automatic job that wakes up and copy data every night from one db to another?
do you want to use a SSIS package? do you want to use a shell script to copy the data? you can use bcp to extract data to a text file and bcp to import it at the main db. There are many ways to transfer data from one db to another.

cocis.


我认为你更善于使用在这种情况下SMO,你以某种方式保存转移条目的最后

日期/时间或另一个有助于下次经理点击转移按钮的字段。这是smo API的一个开始 http://blogs.msdn.com/ b / olivier_pieri / archive / 2004/12/06 / 275825.aspx [ ^ ]

示例显示如何连接到SQL,然后从那里访问注册数据库中的表并写入主数据库上的数据。

您可以阅读更多信息或从Microsoft获得更多SMO样本。

祝您好运!
I my opinion you are better of using SMO in that case, you somehow save the last
date/time of the entries transfered or another field that help for the next time that the manager click on the transfer button. Here is a start on the smo API http://blogs.msdn.com/b/olivier_pieri/archive/2004/12/06/275825.aspx[^]
the sample show just how to connect to SQL, then go from there accessing the tables from the registration db and write the data on the main db.
You can read more or get more SMO samples from Microsoft.
Good Luck!


这篇关于从.sql脚本将数据附加到现有SQL数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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