将数据库复制到另一个位置 [英] Copy database to another location

查看:93
本文介绍了将数据库复制到另一个位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我的数据库位于位置C:\ DB \ Detail.mdf.该数据库是MsSql.我正在一个应用程序中使用该明细数据库.当该应用程序运行时,我尝试将数据库作为额外副本(例如E:\ DB)复制到新位置.但这表明数据库正在被另一个应用程序使用.我尝试手动进行编码.但它不起作用.有什么办法可以做到这一点.如果知道,请告诉我.

Hi,

I have database at location C:\DB\Detail.mdf. The database is MsSql. I am using that Detail Database in one application. While that application is running i try to copy a database to new location as a extra copy (eg.E:\DB). But it is showing as that the database is using by another application. I try''d manually and also in coding. But its not working. Is there any way to do this. If know please tell me.

推荐答案

最短的方法是进行本地备份,将.bak文件复制到远程计算机并在那里进行还原...

可以使用sql managemant studio
完成
也可以用代码制作!
The shortest way is to make a local backup, copy the .bak file to remote machine and make a restore there...

Can be done with sql managemant studio

Can also be made in code!


停止SQL Server(MSSQLSERVER)服务并复制mdf和ldf文件.粘贴其他位置后,启动服务.
Stop the SQL Server (MSSQLSERVER) service and copy the mdf and ldf files. After pasting another location, start the service.


您无法在数据库运行时复制它.您需要将其取脱机分离进行复制.

通过查询脱机
You can not copy the database while it is running. either you need to take it OFFLine or detach it to copy.

Offline by Query
ALTER DATABASE databasename SET Offline



使其脱机然后复制.



make it offline and then copy.


这篇关于将数据库复制到另一个位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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