在服务器之间复制数据库的脚本 [英] Script to copy database between servers

查看:33
本文介绍了在服务器之间复制数据库的脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Spike 此处的答案几乎正是我们所需要的.唯一的障碍是如何在一个脚本中通过链接服务器在一台服务器上运行备份并在另一台服务器上运行恢复?它必须是一个可以转换为仅提供源和目标数据库名称的存储过程的脚本.

The answer from Spike here was very nearly exactly what we needed. The only hurdle is how to have the backup run on one server and the restore run on another through linked server all in one script? It must be a script that can be turned into a stored procedure that's fed only source and destination DB names.

是否存在源服务器是 SQL Server Express 2012 而目标服务器是完整版的问题?

Does it present a problem that the source server is SQL Server Express 2012 whereas the destination is the full version?

它必须是一个脚本,只需更改数据库名称和逻辑名称即可针对任何数据库运行.它适用于需要每次都针对不同的数据库非常定期和完全自动运行的进程.

It has to be a script that can run against any DB by just changing the DB name and logical names. It's for a process that's need to run very regularly and fully automatically against a different DB each time.

另外,为什么不更好地分离,复制 mdf 和 ldf,然后重新附加?

Also, why wouldn't be better to just detach, copy the mdf and ldf, then re-attach?

推荐答案

您可以将数据库从一台服务器复制到另一台服务器,只需按照以下步骤操作 (SQL Server 2008):1.在SSMS中选择源服务器中的数据库.2.右键->任务->复制数据库向导,启动复制数据库向导.输入源和目标凭据并选择附加/分离或 SMO 类型点击下一步,您可以安排或立即运行,点击完成.

You can copy a database from one server to another, just follow those steps (SQL Server 2008): 1.Select the database in the source server in SSMS. 2.Right click ->Tasks->Copy Database Wizard to launch the copy database wizard. Enter the source and destination credentials and select either attach/detach or SMO type click next and you can schedule or run immediately, Click finish.

供您参考:

http://msdn.microsoft.com/en-us/library/ms188664.aspx

这篇关于在服务器之间复制数据库的脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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