Today I have a problem with an Access database that has an N-article record, now want to replace some of these articles, our first thought is to go to the background of a site to a modified article, if there are 1000 articles, then in the background of the site to change 1000 times, it is difficult to imagine what kind of workload. In fact, in an Access database, you can use SQL statements to bulk replace content, just one sentence to solve the problem, the following two ways to solve the problem.
method One: Modify the Query Analyzer in the Access database (I'm using Access 2003 here)
1, open the Access database that you want to modify
2, in the Database "object" click "Query"
3. Click "Create query in Design view"
4, in the appearance of the interface to close the "Show table" small window
5, click the "View" menu, select "SQL View", the query window will appear, you can enter the SQL statement here
6, directly enter the following SQL statements:
Update table SET field =replace (field, "Original character", "replace character")
You can according to the actual situation, the above red Word can be replaced, here for example, suppose the table is Biao, the field content, the original character is xiazai.jb51.net, the substitution character is down1.jb51.net, then the corresponding SQL statement is as follows:
Copy Code code as follows:
Update Biao SET content=replace (content, "xiazai.jb51.net", "down1.jb51.net")
7, click the exclamation point in the toolbar, run it.
method Two: Use ASP program to replace the characters in bulk, the above code has the character length limit problem. There is no limit to this.
The following directly to the ASP program code, we see that we know:
Copy Code code as follows:
' This omits the database connection code
Dim Rs,sql,text
Set rs=server.createobject ("ADODB. Recordset ")
Sql= "Select content from Biao"
Rs. Open sql,conn,1,3
Do but not Rs. Eof
Text=replace (RS ("content"), "Xiazai.jb51.net", "down1.jb51.net")
RS ("content") =text
Rs. Update
Rs. MoveNext
Loop
Rs. Close
Set rs=nothing