how to convert Mdf/ldf database files to .bak file (db restore) using T-SQL or .net code

左心房为你撑大大i 提交于 2019-12-07 06:41:45

问题


I have sql server database files (Mdf/Ldf) and i want to convert them to backup file using T-SQL commands or .net Code (C# or Vb.net).

any suggestions.

thans


回答1:


BACKUP DATABASE [NameOfDatabase] TO  DISK = N'D:\path\filename.bak' 
WITH NOFORMAT, NOINIT,  NAME = N'NameOfDatabase-Full Database Backup', 
SKIP, NOREWIND, NOUNLOAD,  STATS = 10  

Replace NameOfDatabase with name of your database.
Replace D:\path\filename.bak with place you want to backup with
Replace Name = N database name for cosmetic indexing reasons...

Original source - http://forums.asp.net/p/1448416/3870094.aspx



来源:https://stackoverflow.com/questions/4615521/how-to-convert-mdf-ldf-database-files-to-bak-file-db-restore-using-t-sql-or

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!