Because of XX reason, SQL Server to downgrade, so with the following ....
A script can be generated directly from SQL Server's own tools, as follows:
1. Open Microsoft SQL Server managenment Studio
2. Right-click the database >> tasks >> Generate script
3. Follow the prompts to proceed to the next step until you see the Advanced button, such as action
If the generated script file is not large, the generated script executes directly in Query Analyzer
You can also try to generate a file for each object after you execute the
If the script file is large, you need to split the file and execute
If the single file (the entire library) executes too large, you can try this:
1. First group each type of script file after the execution, such as
2. Use the following procedure to perform 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"%><%stringxx =" -"; string[] filelist = Directory.GetFiles (Server.MapPath ("~/website1/xxtables")); if(request["dir"] !=NULL) filelist = Directory.GetFiles (Server.MapPath ("~/website1/"+request["dir"]. ToString ())); foreach(stringFileInfoinchfilelist) {List<string>errorlist=Newlist<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); /// stringstrSQL =System.IO.File.ReadAllText (FileInfo); stringConstr ="data source=.; Uid=sa; [Email protected];d atabase=21744new";//Define link character channelingConstr="Data source=localhost;uid=21744;pwd=123456789;database=21744";//Public networkSqlConnection Conn=NewSqlConnection (CONSTR); Conn. Open (); SqlCommand cmd=NewSqlCommand (); Cmd. Connection=Conn; //cmd.commandtext = strSQL; //Assigning SQL statements to SqlCommand; //cmd. ExecuteNonQuery (); //Conn. Close (); //ArrayList Lists = Lj.executesqlfile (Server.MapPath ("Netshop.sql"));//Call the Executesqlfile () method and reverse back to the ArrayList object;string[] Lists = Strsql.split (New string[] {"\r\ngo\r\n"}, Stringsplitoptions.removeemptyentries); stringTeststr ="";//defines the variables that traverse ArrayList; stringErrorMsg =""; foreach(stringVarcommandtextinchLists) { Try{teststr= Varcommandtext;//traverse the value of the character; //Response.Write (teststr + "|@|<br>");Cmd.commandtext = Teststr;//Assigning SQL statements to SqlCommand;cmd. ExecuteNonQuery (); } Catch(Exception ex) {Errorlist.add (ex). Message); ErrorMsg+ = Teststr +"<br/>"; } //Execution} conn. Close (); Response.Write ("execution Complete OK, the error message is as follows: ErrorMsg:"+ errorList.Count.ToString () +">>"+fileinfo+"<br/>"); }%><! DOCTYPE html>"http://www.w3.org/1999/xhtml">"Server"><meta http-equiv="Content-type"Content="text/html; Charset=utf-8"/> <title></title>"Form1"runat="Server"> <div> </div> </form></body>Of course, if the client environment is supported, you can also use this method
string[]filelist=directory.getfiles (Server.MapPath ("~/xxtables")); foreach(stringFileInfoinchfilelist) { stringsqlConnectionString ="data source=.; Uid=sa; [Email protected];d atabase=21744new"; //sqlconnectionstring = "Data source=localhost;uid=21744;pwd=123456789;database=21744";//Public networkFileInfo file =NewFileInfo (FileInfo); stringScript =file. OpenText (). ReadToEnd (); SqlConnection Conn=NewSqlConnection (sqlconnectionstring); Server server=NewServer (Newserverconnection (conn)); Server. Connectioncontext.executenonquery (script); Response.Write ("finished OK"); Response.Write (FileInfo+"<br/>"); }
If a single file is still relatively large, you can only generate the schema script separately, and then generate the data script (file segmentation for the data script)
Here is the example complete source code
Http://www.haolizi.net/example/view_3253.html
SQL Server 2008 database down to SQL Server 2005 database final scenario Summary