公告
财富商城
积分规则
提问
发文
2020-02-16 05:45发布
在下西门庆
I have a file with .bak extension.
.bak
How can I import this date to a database in SQL Server?
Done
You can use node package, if you often need to restore databases in development process.
Install:
npm install -g sql-bak-restore
Usage:
sql-bak-restore <bakPath> <dbName> <oldDbName> <owner>
Arguments:
!! sqlcmd command line utility should be in your PATH variable.
https://github.com/vladimirbuskin/sql-bak-restore/
RESTORE FILELISTONLY FROM DISK = 'D:\3.0 Databases\DB.bak' RESTORE DATABASE YourDB FROM DISK = 'D:\3.0 Databases\DB.bak'
and you have to move appropriate mdf,ndf & ldf files using
With Move 'primarydatafilename' To 'D:\DB\data.mdf', Move 'secondarydatafile'To 'D:\DB\data1.ndf', Move 'logfilename' To 'D:\DB\log.ldf'
Simply use
sp_restoredb 'Your Database Name' ,'Location From you want to restore'
Example: sp_restoredb 'omDB','D:\abc.bak'
.bak files are database backups. You can restore the backup with the method below:
How to: Restore a Database Backup (SQL Server Management Studio)
The above solutions missed out on where to keep your backup (.bak) file. This should do the trick. It worked for me.
最多设置5个标签!
Done
You can use node package, if you often need to restore databases in development process.
Install:
Usage:
Arguments:
!! sqlcmd command line utility should be in your PATH variable.
https://github.com/vladimirbuskin/sql-bak-restore/
and you have to move appropriate mdf,ndf & ldf files using
Simply use
sp_restoredb 'Your Database Name' ,'Location From you want to restore'
Example: sp_restoredb 'omDB','D:\abc.bak'
.bak files are database backups. You can restore the backup with the method below:
How to: Restore a Database Backup (SQL Server Management Studio)
The above solutions missed out on where to keep your backup (.bak) file. This should do the trick. It worked for me.