Something about restore and bak sql server

Here is a sample for restore and bak sql server database:

alter database pubs set SINGLE_USER with rollback IMMEDIATE use master
RESTORE DATABASE pubs
   FROM DISK = 'c:\pubs.bak'
    WITH NORECOVERY,  MOVE 'pubs' TO 'C:\xx\pubs.mdf',
   MOVE 'pubs_log' TO 'C:\xx\pubs_log.ldf'
//备份
BACKUP DATABASE pubs
   TO DISK = 'c:\pubs.bak'
//条目
RESTORE FILELISTONLY
   FROM DISK = 'c:\pubs.bak'


   (1)数据备份语句:backup database  数据库名 to disk='保存路径\dbName.bak'
    (2)数据恢复语句:restore database 数据库名 from disk='保存路径\dbName.bak'  WITH MOVE 'dbName_Data' TO 'c:\tcomcrm20041217.mdf', --数据文件还原后存放的新位置
MOVE 'dbName_Log' TO 'c:\comcrm20041217.ldf' ----日志文件还原后存放的新位置
关于这两个语句还有更详细的介绍:http://blog.csdn.net/holyrong/archive/2007/08/29/1764105.aspx
另外,如果出现:“尚未备份数据库的日志尾部”错误,可以在还原语句后加上 With Replace 或 With stopat

 

The sample tell us how to restore or bak a whole database,then,for table:

If you want to copy a table or some tables between two database in a same instance,it's easy:

select * into destinations.dbo.table1 from source.dbo.table2

If you want to transfer data from 2 diferent instance or different server,

you can use the tool of sql server:Import and Export Data.

posted @ 2012-05-20 01:33  answerlkh  阅读(131)  评论(0编辑  收藏  举报