In fact, you can use SQL statements in the Access database to replace the content in batches. You only need one sentence to solve the problem. The following two methods are used to solve the problem.
In fact, you can use SQL statements in the Access database to replace the content in batches. You only need one sentence to solve the problem. The following two methods are used to solve the problem.
Today, I encountered a problem where an Access database stores N article records. Now I want to replace some of the content in these articles. The first thing we think of is to go to the website background to modify an article, if there are 1000 articles, you can change the number of times in the background of the website. It is hard to imagine the workload. In fact, you can use SQL statements in the Access database to replace the content in batches. You only need one sentence to solve the problem. The following two methods are used to solve the problem.
Method 1: Modify it by using the query analyzer in the Access Database (Access 2003 is used here)
1. Open the Access database to be modified
2. Click "query" in "object" of the database"
3. Click "create query in design view"
4. Close the "display table" window on the displayed page.
5. Click "View" and select "SQL View". The query window is displayed. You can enter the SQL statement here.
6. Enter the following SQL statement:
Update table SET field = replace (field, "original character", "replacement character ")
You can replace the red text above according to the actual situation. For example, assume that the table is biao, the field is content, the original character is xiazai.jb51.net, And the replacement character is down1.jb51.net, the corresponding SQL statement is as follows:
The Code is as follows:
Update biao SET content = replace (content, "xiazai.jb51.net", "down1.jb51.net ")
7. Click the exclamation point in the toolbar to run it.
Method 2: Use an ASP program to replace characters in batches. The above Code has the character length limit. There is no limit on this.
The ASP program code is provided below. You can see it at first glance:
The Code is as follows:
'The database connection code is omitted here
Dim rs, SQL, text
Set rs = Server. CreateObject ("ADODB. Recordset ")
SQL = "Select content From biao"
Rs. Open SQL, conn, 1, 3
Do While 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