sql server 2008数据库 降为 sql server 2005数据库 最终方案总结
由于xx原因,sql server 要降级,所以有了下文。。。。
一 直接 通过sql server 自带工具 生成脚本即可,具体操作方法如下:
1.打开 Microsoft Sql Server Managenment Studio
2.右键该数据库>>任务>>生成脚本
3.按提示操作下一步,直到看到高级按钮,这时如下图操作

如果生成的脚本文件不大,将生成的脚本直接在查询分析器 执行即可
也可以尝试将每个对象生成一个文件后执行
如果脚本文件较大则 需要 分割文件后执行
如果单文件(整个库)执行过大的时候,可以尝试这样:
1.先把每一类脚本文件分组后执行,如下图

2.用以下程序逐个执行 xxtables xxviews xxfunctions xxproc
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TestSql.aspx.cs" Inherits="TestSql" %>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.IO" %>
<% string xx = ""; string[] filelist = Directory.GetFiles(Server.MapPath("~/website1/xxtables"));
if (Request["dir"] != null) filelist = Directory.GetFiles(Server.MapPath("~/website1/"+Request["dir"].ToString()));
foreach (string fileInfo in filelist)
{
List<string>errorList=new List<string>(); //string fileName = "users.sql";
//if (Request["sqlfile"] != null) fileName = Request["sqlfile"].ToString();
//string strSql = System.IO.File.ReadAllText(Server.MapPath("~/website1/" + fileName + ""));
////Response.Write(strSql);
///
string strSql = System.IO.File.ReadAllText(fileInfo); string constr = "data source=.;uid=sa;pwd=1@1.com;database=21744new"; // 定义链接字符窜 constr = "data source=localhost;uid=21744;pwd=123456789;database=21744"; //公网 SqlConnection conn = new SqlConnection(constr);
conn.Open(); SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
//cmd.CommandText = strSql; //为SqlCommand赋Sql语句;
//cmd.ExecuteNonQuery();
//conn.Close(); //ArrayList Lists = Lj.ExecuteSqlFile(Server.MapPath("NetShop.sql")); //调用ExecuteSqlFile()方法,反回 ArrayList对象;
String[] Lists = strSql.Split(new string[] {"\r\nGO\r\n"}, StringSplitOptions.RemoveEmptyEntries);
string teststr = ""; //定义遍历ArrayList 的变量;
string errorMsg = "";
foreach (string varcommandText in Lists)
{
try
{
teststr = varcommandText; //遍历并符值;
//Response.Write(teststr + "|@|<br>");
cmd.CommandText = teststr; //为SqlCommand赋Sql语句;
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
errorList.Add(ex.Message);
errorMsg += teststr + "<br/>";
}
//执行
}
conn.Close(); Response.Write("执行完毕 ok啦,错误信息如下:errorMsg:" + errorList.Count.ToString()+">>"+fileInfo+"<br/>");
} %>
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div> </div>
</form>
</body>
</html>
当然如果客户端环境支持的话,也可以通过这种方式
string[]filelist=Directory.GetFiles(Server.MapPath("~/xxtables"));
foreach (string fileInfo in filelist)
{
string sqlConnectionString = "data source=.;uid=sa;pwd=1@1.com;database=21744new";
//sqlConnectionString = "data source=localhost;uid=21744;pwd=123456789;database=21744";//公网
FileInfo file = new FileInfo(fileInfo);
string script = file.OpenText().ReadToEnd();
SqlConnection conn = new SqlConnection(sqlConnectionString);
Server server = new Server(new ServerConnection(conn));
server.ConnectionContext.ExecuteNonQuery(script);
Response.Write("完毕 OK");
Response.Write(fileInfo+"<br/>");
}
如果单个文件还是比较大的话,那只能先单独生成架构脚本,再生成数据脚本了(对数据脚本 进行文件分割)
下面是该例子完整源码
http://www.haolizi.net/example/view_3253.html
sql server 2008数据库 降为 sql server 2005数据库 最终方案总结的更多相关文章
- 使用SQL Server 2008远程链接时SQL数据库不成功的解决方法
关键设置: 第一步(SQL2005.SQL2008): 开始-->程序-->Microsoft SQL Server 2008(或2005)-->配置工具-->SQL Serv ...
- 【转】SQL Server 2008 事件探查器(SQL SERVER Profiler)
跟踪数据库sql语句的执行情况.例:一个系统,用到了sql server 数据库,这个系统共有500张表,当用户在前台页面做某一个操作时,比如插入,登录等等,我们想知道此刻是在对哪一张表操作,打开事件 ...
- SQL Server 2008 R2升级到SQL Server 2012 SP1
1.建议对生产环境对的数据库升级之前做好备份,以防不测. 2.从SQL Server 2008 R2 升级到SQL Server 2012 SP1,需要先安装SQL Server 2008 R2 的S ...
- 安装 SQL Server 2008 和管理工具 SQL Server 2008 management studio 及相关问题解决
Sql Server 2008 问题小总结 http://www.lihengyu.com/blog/4877.html 安装 SQL Server 2008 和管理工具 SQL Server 200 ...
- sql server 2008 64位连接sql 2000服务器的时候出现
来源 https://blog.csdn.net/loeley/article/details/7095741 sql server 2008 64位连接sql 2000服务器的时候出现以下提示: 链 ...
- Windows Server 2008 R2 SP1安装SQL 2012安装报错之0x858C001B
使用Windows Server 2008 R2 SP1安装SQL 2012的时候总是报这样一个错: SQL Server Setup has encountered the following er ...
- SQL Server 2008 R2 SP3 and SQL Server 2008 SP4 are now available!
时间 2014-10-02 00:00:00 SQL Server Team Blog 原文 http://blogs.technet.com/b/dataplatforminsider/arc ...
- 阿里云服务器Windows Server 2008/2012部署Office Web Server 2013
以前成功将Office Web Server 2013部署在了本地服务器上,此次是将Office Web Server 2013部署在阿里云服务器Windows Server 2008和2012上,中 ...
- SQL SERVER 2008 服务器登录名、角色、数据库用户、角色、架构的关系
sql server登录名.服务器角色.数据库用户.数据库角色.架构区别联系 1.一个数据库用户可以对应多个架构(架构是表容器).架构里面包含的是数据库表. 2.一个数据库角色有可能涉及多个架构.数据 ...
- SQL Server 2008教程和Microsoft® SQL Server® 2008 R2 SP2 - Express Edition下载
教程 SQL Server 2008 Tutorialhttp://www.quackit.com/sql_server/sql_server_2008/tutorial/ 数据库下载 Microso ...
随机推荐
- UVALive 5881
DES:给出一个数列.然后有q个询问,对给定的区间内是否有重复的数.如果有输出任意一个重复的.如果没有输出OK. 开始以为是线段树.后来发现.只是水的比较隐蔽.感觉这个方法还是很聪明的.把每个点的最近 ...
- mongodb的capped Collection集合
db.createCollection(name, {capped: true, autoIndexId: true, size: 1000, max :100} ) name:集合的名字 cappe ...
- sgu 129 Inheritance 凸包,线段交点,计算几何 难度:2
129. Inheritance time limit per test: 0.25 sec. memory limit per test: 4096 KB The old King decided ...
- [转载]oracle游标概念讲解
原文URL:http://www.2cto.com/database/201203/122387.html ORACLE游标概念讲解 什么是游标? ①从表中检索出结果集,从中每次指向一条记录进行交互 ...
- JDBCTemplate使用
业务上,手机App(离线状态下的数据),在在线的时候需要往服务端上传,由于App上的SQLite数据库里的需要 同步数据的表 跟服务端的数据库表结构一致,所以为了同步数据的方便性,我们决定App在进行 ...
- DevExpress WPF入门指南:如何自动或手动添加DXSplashScreen控件
<DevExpress v17.2 版本更新公开课>点击报名 DevExpress WPF 的 DXSplashScreen 控件在应用加载的时候显示一个启动界面.添加DXSplashSc ...
- axure 认证授权注册码2017-12-25
Licensee: University of Science and Technology of China (CLASSROOM)Key: DTXRAnPn1P65Rt0xB4eTQ+4bF5IU ...
- ZOJ 17届校赛 Knuth-Morris-Pratt Algorithm( 水题)
In computer science, the Knuth-Morris-Pratt string searching algorithm (or KMP algorithm) searches f ...
- Linux下常用的ftp操作命令
Linux下常用的ftp操作命令 =========== 完美的分割线 ============= 1.登陆ftp服务器 ftp [IP] [PORT] # 登陆ftp服务器,本机登陆可以不写IP 实 ...
- PLsql登录数据库提示密码即将过期-
小哥询问,PL*SQL用户登录后弹出警告:咋整? ORA-28002:the password will expire within 7 days密码在7天内将到期 do you wish to ch ...