Something about restore and bak sql server
2012-05-20 01:33
381 查看
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.
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.
相关文章推荐
- How to backup and restore database in SQL Server
- MS SQL错误:SQL Server failed with error code 0xc0000000 to spawn a thread to process a new login or connection. Check the SQL Server error log and the Windows event logs for information about possible related problems
- SQL Server Database Backup and Restore in C#
- SQL Server backup and restore
- [转]Configure Network Drive Visible for SQL Server During Backup and Restore Using SSMS
- backup and restore database on Microsoft SQL Server 2005
- [SQL Server][FILESTREAM] -- How to Backup and Restore a SQL Server FILESTREAM Enabled Database
- 转载:Restore SQL Server database and overwrite existing database
- 在MSDB中清除SQL Server 还原备份历史数据(Purging MSDB Backup and Restore History from SQL Server)
- sql server try catch and transaction的几个要点
- Saving and Displaying Photos in SQL Server using ASP.NET and FileUpload Control
- Importing Excel data with SQL Server Integration Services and dealing with unicode and non-unicode data issues
- Sql server restore script(还原数据库正确的步骤)
- Beginning T-SQL with Microsoft SQL Server 2005 and 2008
- A High Level Comparison Between Oracle and SQL Server - Part II
- Verify that the instance name is correct and that SQL Server is configured to allow remote connections.
- Something about file's read and write (C++)
- numeric and int in sql server
- Turning Off and On Identity Column in SQL Server
- VBS Get Sql Server Table Data and Export to CSV File...