问一个简单的SQL的句子,怎么备份SQLServer2000的一个数据库到文件

大雨仔 2003-08-30 08:37:41
很简单哦
...全文
76 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
孟子E章 2003-08-30
  • 打赏
  • 举报
回复
public class BackupDB
{

public bool BackupDatabase()
{
// Create Instance of Connection and Command Object
SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["connectionString"].ToString());
string sBackup = "BACKUP DATABASE " + myConnection.Database + " TO DISK = 'c:\\sql.bak' WITH NOINIT";
SqlCommand myCommand = new SqlCommand(sBackup, myConnection);

// Open the database connection and execute the command
myConnection.Open();
myCommand.ExecuteNonQuery();
myConnection.Close();

return true;
}
}
canyqf 2003-08-30
  • 打赏
  • 举报
回复
USE master
BACKUP DATABASE { database_name | @database_name_var }
TO DISK= 'path'
WITH ...

110,529

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧