一、备份SQL Server数据库
string SqlStr1 = "Server=(local);database='" + this.DropDownList1.SelectedValue + "';Uid=sa;Pwd=";string SqlStr2 = "backup database " + this.DropDownList1.SelectedValue + " to disk='" + this.TextBox1.Text.Trim() + ".bak'";SqlConnection con = new SqlConnection(SqlStr1);con.Open();try{if (File.Exists(this.TextBox1.Text.Trim())){Response.Write("");return;}SqlCommand com = new SqlCommand(SqlStr2, con);com.ExecuteNonQuery();Response.Write("");}catch (Exception error){Response.Write(error.Message);Response.Write("");}finally{con.Close();}
string SqlStr1 = "Server=(local);database='" +
this.DropDownList1.SelectedValue + "';Uid=sa;Pwd=";string SqlStr2 = "backup database " + this.DropDownList1.SelectedValue +
" to disk='" + this.TextBox1.Text.Trim() + ".bak'";SqlConnection con = new SqlConnection(SqlStr1);con.Open();try{if (File.Exists(this.TextBox1.Text.Trim())){Response.Write("");return;}SqlCommand com = new SqlCommand(SqlStr2, con);com.ExecuteNonQuery();Response.Write("");}catch (Exception error){Response.Write(error.Message);Response.Write("");}finally{con.Close();}
二、还原SQL Server数据库
string path = this.FileUpload1.PostedFile.FileName; //获得备份路径及数据库名称string dbname = this.DropDownList1.SelectedValue;string SqlStr1 = "Server=(local);database='" + this.DropDownList1.SelectedValue + "';Uid=sa;Pwd=";string SqlStr2 = "use master restore database " + dbname + " from disk='" + path + "'";SqlConnection con = new SqlConnection(SqlStr1);con.Open();try{SqlCommand com = new SqlCommand(SqlStr2, con);com.ExecuteNonQuery();Response.Write("");}catch (Exception error){Response.Write(error.Message);Response.Write("");}finally{con.Close();}
string path = this.FileUpload1.PostedFile.FileName;
//获得备份路径及数据库名称string dbname = this.DropDownList1.SelectedValue;string SqlStr1 = "Server=(local);database='" +
this.DropDownList1.SelectedValue + "';Uid=sa;Pwd=";string SqlStr2 = "use master restore database " +
dbname + " from disk='" + path + "'";SqlConnection con = new SqlConnection(SqlStr1);con.Open();try{SqlCommand com = new SqlCommand(SqlStr2, con);com.ExecuteNonQuery();Response.Write("");}catch (Exception error){Response.Write(error.Message);Response.Write("");}finally{con.Close();}
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流
SQL Server会为无索引列自动创建统计以提升查询效率,通过_WA_Sys前缀和索引属性函数可区分统计类型。自动统计数量异常可能暗示索引策略需优化,建议定期检查统计表与实际索引的关联性。...
哈米德网络科技专注于网站建设与定制开发,提供企业官网、品牌网站、营销型网站、电商网站、响应式网页设计以及后端系统开发。通过高性能架构、专业UI设计与稳定运维支持,为企业打造高品质、高转化率的线上业务入口,助力品牌数字化升级。
哈米德网络科技提供专业的移动端与 APP 定制开发服务,涵盖 iOS / Android 原生开发、跨平台应用、企业级移动系统、小程序与 H5 应用。通过高性能架构、专业UI设计与稳定系统能力,为企业打造安全、流畅、功能完善的移动应用解决方案,助力业务数字化升级。
哈米德网络科技提供专业的微信小程序定制开发服务,涵盖企业小程序、电商小程序、服务类小程序、预约系统、小程序商城、微信生态运营及后台管理系统。以高性能架构、优质UI设计与稳健的技术能力,为企业打造便捷高效的微信数字化应用。
哈米德网络科技提供全方位的技术支持服务,包括系统维护、网站运维、服务器管理、BUG修复、功能优化、数据备份、性能监控与安全防护等。以快速响应、高稳定性和专业技术团队,为企业提供可靠的技术保障与长期服务支持。
了解我们的服务项目,包括高流量网站建设、软件开发、信息化解决方案及网络咨询服务,助力企业提升数字化能力,实现高效运营与技术创新。