---
title: "sqlServer中with replace、move...to的使用例子"
author: "icyheart"
date: "2010-04-29T11:17:16Z"
tags: []
categories: ["数据库"]
slug: "sqlserver-with-replace-move-to"
draft: false
lastmod: "2010-04-29T11:17:16Z"
id: 655964
url: "https://sucre.iteye.com/blog/655964"
---

今天在做数据库还原的时候提示不能还原，没办法，只能用命令就进行还原了，为了使还原更顺利的进行，所以使用了with replace,move...to这个用法，具体如下：

```
restore database shenlianli from disk='e:\cj' with replace,
move 'iscp2_Data' to 'e:\Program Files\Microsoft SQL Server\MSSQL\data\shenlianli_Data.MDF',
move 'iscp2_Log' to 'e:\Program Files\Microsoft SQL Server\MSSQL\data\shenlianli_Log.ldf'
```

 

还原文件叫cj，要还原到shenlianli的数据库中，下面move两行主要是将cj中的日志文件移动到现在的shenlianli数据库日志文件中，这样才会还原成功，在move的时候要注意后面路径问题，这个很重要，如果路径不对那肯定是还原不成功的。