简体   繁体   English

如何使用T-SQL或.net代码将Mdf / ldf数据库文件转换为.bak文件(db restore)

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

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). 我有sql server数据库文件(Mdf / Ldf),我想使用T-SQL命令或.net代码(C#或Vb.net)将它们转换为备份文件。

any suggestions. 有什么建议么。

thans thans

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 原始来源 - http://forums.asp.net/p/1448416/3870094.aspx

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何通过C#以编程方式在不使用.mdf或.ldf文件的情况下将.bak文件还原到新服务器? - How can I restore a .bak file to a new server without using the .mdf or .ldf files, programmatically with C#? 从bak和ldf文件还原数据库 - Restore database from bak and ldf files 如何在T-SQL中找到mdf / ldf位置? - How can I find mdf/ldf locations in T-SQL? 如何调用远程 T-SQL 过程将 remote.bak 数据库文件恢复到远程 SQL 服务器实例? - How do I call a remote T-SQL procedure to restore a remote .bak database file to a remote SQL Server instance? 导出SQL Server MDF和LDF数据库文件 - Exporting SQL Server MDF and LDF database files 仅使用MDF文件而不使用LDF还原SQL Server数据库 - Restoring SQL Server database using just the MDF file without LDF 从MDF文件还原数据库,丢失的LDF和数据库未完全关闭 - Restore DB from MDF file, lost LDF and DB was not cleanly shutdown 如何使用c#从文件系统和SQL Server中删除动态生成的数据库文件(.MDF和.LDF) - How to delete a dynamically generated database file (.MDF and .LDF) from the filesystem and from SQL server using c# 如何还原对其MDF和LDF文件使用相同命名方案的多个SQL Server数据库 - How to restore multiple SQL Server databases that use the same naming scheme for their MDF and LDF files 如何将bak文件转换为sql文件(将SQL bak文件转换为mysql支持)并执行该文件以自动还原 - How to convert bak file into sql file (sql bak file to mysql supported) and the execute that file to restore automatically
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM